diff options
author | 木杉 <zhmushan@qq.com> | 2019-12-12 13:05:26 +0800 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-12-12 13:05:26 +0800 |
commit | 7f27f649cca0e928a422aaa6182988087338e435 (patch) | |
tree | eab4e39feddd70aa51a1481ffcacdbc775b015e2 /std/http/file_server.ts | |
parent | d146d45861708bcf1879563a545a2c8b8f96bd80 (diff) |
fix: file_server swallowing permission errors (#3467)
Diffstat (limited to 'std/http/file_server.ts')
-rwxr-xr-x | std/http/file_server.ts | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/std/http/file_server.ts b/std/http/file_server.ts index 41aac5e45..e3caae882 100755 --- a/std/http/file_server.ts +++ b/std/http/file_server.ts @@ -6,7 +6,7 @@ // TODO Add tests like these: // https://github.com/indexzero/http-server/blob/master/test/http-server-test.js -const { ErrorKind, cwd, args, stat, readDir, open } = Deno; +const { ErrorKind, DenoError, cwd, args, stat, readDir, open } = Deno; import { posix } from "../path/mod.ts"; import { listenAndServe, @@ -142,10 +142,7 @@ async function serveDir( } async function serveFallback(req: ServerRequest, e: Error): Promise<Response> { - if ( - e instanceof Deno.DenoError && - (e as Deno.DenoError<Deno.ErrorKind.NotFound>).kind === ErrorKind.NotFound - ) { + if (e instanceof DenoError && e.kind === ErrorKind.NotFound) { return { status: 404, body: encoder.encode("Not found") @@ -297,6 +294,7 @@ listenAndServe( response = await serveFile(req, fsPath); } } catch (e) { + console.error(e.message); response = await serveFallback(req, e); } finally { if (CORSEnabled) { |