mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(ext/node): use ERR_NOT_IMPLEMENTED for notImplemented (#26853)
This commit is contained in:
parent
9331e2cef0
commit
7d9ba09f5a
3 changed files with 26 additions and 3 deletions
|
@ -17,6 +17,7 @@ const {
|
||||||
import { TextDecoder, TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
import { TextDecoder, TextEncoder } from "ext:deno_web/08_text_encoding.js";
|
||||||
import { errorMap } from "ext:deno_node/internal_binding/uv.ts";
|
import { errorMap } from "ext:deno_node/internal_binding/uv.ts";
|
||||||
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
import { codes } from "ext:deno_node/internal/error_codes.ts";
|
||||||
|
import { ERR_NOT_IMPLEMENTED } from "ext:deno_node/internal/errors.ts";
|
||||||
|
|
||||||
export type BinaryEncodings = "binary";
|
export type BinaryEncodings = "binary";
|
||||||
|
|
||||||
|
@ -34,8 +35,7 @@ export type TextEncodings =
|
||||||
export type Encodings = BinaryEncodings | TextEncodings;
|
export type Encodings = BinaryEncodings | TextEncodings;
|
||||||
|
|
||||||
export function notImplemented(msg: string): never {
|
export function notImplemented(msg: string): never {
|
||||||
const message = msg ? `Not implemented: ${msg}` : "Not implemented";
|
throw new ERR_NOT_IMPLEMENTED(msg);
|
||||||
throw new Error(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function warnNotImplemented(msg?: string) {
|
export function warnNotImplemented(msg?: string) {
|
||||||
|
|
|
@ -2390,6 +2390,15 @@ export class ERR_INVALID_RETURN_VALUE extends NodeTypeError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ERR_NOT_IMPLEMENTED extends NodeError {
|
||||||
|
constructor(message?: string) {
|
||||||
|
super(
|
||||||
|
"ERR_NOT_IMPLEMENTED",
|
||||||
|
message ? `Not implemented: ${message}` : "Not implemented",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ERR_INVALID_URL extends NodeTypeError {
|
export class ERR_INVALID_URL extends NodeTypeError {
|
||||||
input: string;
|
input: string;
|
||||||
constructor(input: string) {
|
constructor(input: string) {
|
||||||
|
@ -2862,6 +2871,7 @@ export default {
|
||||||
ERR_INVALID_SYNC_FORK_INPUT,
|
ERR_INVALID_SYNC_FORK_INPUT,
|
||||||
ERR_INVALID_THIS,
|
ERR_INVALID_THIS,
|
||||||
ERR_INVALID_TUPLE,
|
ERR_INVALID_TUPLE,
|
||||||
|
ERR_NOT_IMPLEMENTED,
|
||||||
ERR_INVALID_URI,
|
ERR_INVALID_URI,
|
||||||
ERR_INVALID_URL,
|
ERR_INVALID_URL,
|
||||||
ERR_INVALID_URL_SCHEME,
|
ERR_INVALID_URL_SCHEME,
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
import * as perfHooks from "node:perf_hooks";
|
import * as perfHooks from "node:perf_hooks";
|
||||||
import { performance, PerformanceObserver } from "node:perf_hooks";
|
import {
|
||||||
|
monitorEventLoopDelay,
|
||||||
|
performance,
|
||||||
|
PerformanceObserver,
|
||||||
|
} from "node:perf_hooks";
|
||||||
import { assertEquals, assertThrows } from "@std/assert";
|
import { assertEquals, assertThrows } from "@std/assert";
|
||||||
|
|
||||||
Deno.test({
|
Deno.test({
|
||||||
|
@ -68,3 +72,12 @@ Deno.test("[perf_hooks]: eventLoopUtilization", () => {
|
||||||
assertEquals(typeof obj.active, "number");
|
assertEquals(typeof obj.active, "number");
|
||||||
assertEquals(typeof obj.utilization, "number");
|
assertEquals(typeof obj.utilization, "number");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("[perf_hooks]: monitorEventLoopDelay", () => {
|
||||||
|
const e = assertThrows(() => {
|
||||||
|
monitorEventLoopDelay({ resolution: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
assertEquals((e as any).code, "ERR_NOT_IMPLEMENTED");
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue