From 18d495c7d17cf3fce3835e732094d058f51eddaa Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 15 Aug 2018 23:36:48 -0400 Subject: Better error handling in src/handlers.rs Introduces error codes that are shared between JS/RS Fixes #526. --- js/unit_tests.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'js/unit_tests.ts') diff --git a/js/unit_tests.ts b/js/unit_tests.ts index 96341b4a2..ef65519f6 100644 --- a/js/unit_tests.ts +++ b/js/unit_tests.ts @@ -92,6 +92,21 @@ test(async function tests_readFileSync() { assertEqual(pkg.name, "deno"); }); +/* TODO We should be able to catch specific types. +test(function tests_readFileSync_NotFound() { + let caughtError = false; + let data; + try { + data = readFileSync("bad_filename"); + } catch (e) { + caughtError = true; + assert(e instanceof deno.NotFound); + } + assert(caughtError); + assert(data === undefined); +}); +*/ + test(async function tests_fetch() { const response = await fetch("http://localhost:4545/package.json"); const json = await response.json(); -- cgit v1.2.3