mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
create serialize-error
This commit is contained in:
parent
8f13edab1e
commit
b395df0932
4 changed files with 57 additions and 0 deletions
5
serialize-error/deno.json
Normal file
5
serialize-error/deno.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"imports": {
|
||||
"serialize-error": "npm:serialize-error@^12.0.0"
|
||||
}
|
||||
}
|
32
serialize-error/deno.lock
generated
Normal file
32
serialize-error/deno.lock
generated
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"npm:@types/node@*": "22.5.4",
|
||||
"npm:serialize-error@*": "12.0.0"
|
||||
},
|
||||
"npm": {
|
||||
"@types/node@22.5.4": {
|
||||
"integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==",
|
||||
"dependencies": [
|
||||
"undici-types"
|
||||
]
|
||||
},
|
||||
"serialize-error@12.0.0": {
|
||||
"integrity": "sha512-ZYkZLAvKTKQXWuh5XpBw7CdbSzagarX39WyZ2H07CDLC5/KfsRGlIXV8d4+tfqX1M7916mRqR1QfNHSij+c9Pw==",
|
||||
"dependencies": [
|
||||
"type-fest"
|
||||
]
|
||||
},
|
||||
"type-fest@4.33.0": {
|
||||
"integrity": "sha512-s6zVrxuyKbbAsSAD5ZPTB77q4YIdRctkTbJ2/Dqlinwz+8ooH2gd+YA7VA6Pa93KML9GockVvoxjZ2vHP+mu8g=="
|
||||
},
|
||||
"undici-types@6.19.8": {
|
||||
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw=="
|
||||
}
|
||||
},
|
||||
"workspace": {
|
||||
"dependencies": [
|
||||
"npm:serialize-error@12"
|
||||
]
|
||||
}
|
||||
}
|
7
serialize-error/main.ts
Normal file
7
serialize-error/main.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { addKnownErrorConstructor } from "npm:serialize-error";
|
||||
|
||||
export class E extends Error {
|
||||
code = "ERR";
|
||||
}
|
||||
|
||||
addKnownErrorConstructor(E);
|
13
serialize-error/test.ts
Normal file
13
serialize-error/test.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import assert from "node:assert";
|
||||
import { deserializeError, serializeError } from "npm:serialize-error";
|
||||
import { E } from "./main.ts";
|
||||
|
||||
Deno.test("serializeError", () => {
|
||||
const e = serializeError(new E());
|
||||
assert(e.code === "ERR");
|
||||
assert(e.stack?.match(/^Error\n/));
|
||||
});
|
||||
|
||||
Deno.test("deserializeError", () => {
|
||||
assert(deserializeError({ name: "E", message: "🦄" }) instanceof E);
|
||||
});
|
Loading…
Add table
Reference in a new issue