From ee51c3ddd90f6f4e852a65895519768c8a815116 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Thu, 20 Jan 2022 12:29:37 +0900 Subject: [PATCH] fix(cli/dts): add NotSupported error type (#13432) --- cli/dts/lib.deno.ns.d.ts | 1 + cli/tests/unit/error_test.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cli/tests/unit/error_test.ts diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index 46b4bda712..92eaffc765 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -85,6 +85,7 @@ declare namespace Deno { export class BadResource extends Error {} export class Http extends Error {} export class Busy extends Error {} + export class NotSupported extends Error {} } /** The current process id of the runtime. */ diff --git a/cli/tests/unit/error_test.ts b/cli/tests/unit/error_test.ts new file mode 100644 index 0000000000..444b0445ac --- /dev/null +++ b/cli/tests/unit/error_test.ts @@ -0,0 +1,24 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +import { assert } from "./test_util.ts"; + +Deno.test("Errors work", () => { + assert(new Deno.errors.NotFound("msg") instanceof Error); + assert(new Deno.errors.PermissionDenied("msg") instanceof Error); + assert(new Deno.errors.ConnectionRefused("msg") instanceof Error); + assert(new Deno.errors.ConnectionReset("msg") instanceof Error); + assert(new Deno.errors.ConnectionAborted("msg") instanceof Error); + assert(new Deno.errors.NotConnected("msg") instanceof Error); + assert(new Deno.errors.AddrInUse("msg") instanceof Error); + assert(new Deno.errors.AddrNotAvailable("msg") instanceof Error); + assert(new Deno.errors.BrokenPipe("msg") instanceof Error); + assert(new Deno.errors.AlreadyExists("msg") instanceof Error); + assert(new Deno.errors.InvalidData("msg") instanceof Error); + assert(new Deno.errors.TimedOut("msg") instanceof Error); + assert(new Deno.errors.Interrupted("msg") instanceof Error); + assert(new Deno.errors.WriteZero("msg") instanceof Error); + assert(new Deno.errors.UnexpectedEof("msg") instanceof Error); + assert(new Deno.errors.BadResource("msg") instanceof Error); + assert(new Deno.errors.Http("msg") instanceof Error); + assert(new Deno.errors.Busy("msg") instanceof Error); + assert(new Deno.errors.NotSupported("msg") instanceof Error); +});