@visulima/error-handler 2.0.0-alpha.11 → 2.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/error-handler/html-error-handler.d.ts +13 -12
- package/dist/error-handler/json-error-handler.d.ts +13 -12
- package/dist/error-handler/jsonapi-error-handler.d.ts +3 -2
- package/dist/error-handler/jsonp-error-handler.d.ts +13 -13
- package/dist/error-handler/problem-error-handler.d.ts +3 -6
- package/dist/error-handler/text-error-handler.d.ts +12 -11
- package/dist/error-handler/xml-error-handler.d.ts +24 -23
- package/dist/handler/cli-handler.d.ts +27 -4
- package/dist/handler/http/fetch-handler.d.ts +8 -7
- package/dist/handler/http/node-handler.d.ts +8 -8
- package/dist/index.d.ts +12 -14
- package/dist/packem_shared/types.d-C763gSYq.d.ts +13 -0
- package/package.json +4 -4
- package/dist/error-handler/create-negotiated-error-handler.d.ts +0 -4
- package/dist/error-handler/fetch-create-negotiated-error-handler.d.ts +0 -3
- package/dist/error-handler/fetch-html-error-handler.d.ts +0 -3
- package/dist/error-handler/utils/add-status-code-to-response.d.ts +0 -3
- package/dist/error-handler/utils/send-json.d.ts +0 -9
- package/dist/error-handler/utils/set-error-headers.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## @visulima/error-handler [2.0.0-alpha.12](https://github.com/visulima/visulima/compare/@visulima/error-handler@2.0.0-alpha.11...@visulima/error-handler@2.0.0-alpha.12) (2026-04-22)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **error-debugging:** resolve eslint and formatting issues ([7d0ada8](https://github.com/visulima/visulima/commit/7d0ada8787bf624df5a7d504448a4d1b69165aba))
|
|
6
|
+
* **error-debugging:** resolve eslint and type-safety issues ([886dbff](https://github.com/visulima/visulima/commit/886dbffe3f744c9493fcc54e781de3fd21eebf78))
|
|
7
|
+
* **error-handler:** remove unused [@ts-expect-error](https://github.com/ts-expect-error) on end() overload ([a8eb6a6](https://github.com/visulima/visulima/commit/a8eb6a6ab8d42c1a6881dda5c605a4d20dde069f))
|
|
8
|
+
* **error-handler:** resolve eslint and formatting issues ([324f5d8](https://github.com/visulima/visulima/commit/324f5d89f1bcceac4fbe44c6002040aa63be1ec9))
|
|
9
|
+
* Remove JSR configuration generation script and generated jsr.json files ([#616](https://github.com/visulima/visulima/issues/616)) ([533744b](https://github.com/visulima/visulima/commit/533744b103b74896941db5b727173e617a27a63b))
|
|
10
|
+
|
|
11
|
+
### Miscellaneous Chores
|
|
12
|
+
|
|
13
|
+
* bump engines.node to ^22.14.0 || >=24.10.0 ([c3d0931](https://github.com/visulima/visulima/commit/c3d0931d1504e4f21ebf50ea680cfa7ce4ba15ce))
|
|
14
|
+
* **error-handler:** apply formatter and lint fixes ([9ab7d48](https://github.com/visulima/visulima/commit/9ab7d48758f89b434e8c463c45f94eedc4619ab9))
|
|
15
|
+
* **error-handler:** enforce curly braces and apply lint fixes ([ced1569](https://github.com/visulima/visulima/commit/ced1569c34fde28975eda76e5e84db6d87059865))
|
|
16
|
+
* fixed jsr.json ([5d85e51](https://github.com/visulima/visulima/commit/5d85e5179de38e284ec433b14d77c71a1619c8d6))
|
|
17
|
+
|
|
18
|
+
### Continuous Integration
|
|
19
|
+
|
|
20
|
+
* disable isolatedDeclarationTransformer ([d5845d8](https://github.com/visulima/visulima/commit/d5845d888012fbe20a020cb2c02ec57269356e56))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Dependencies
|
|
24
|
+
|
|
25
|
+
* **@visulima/boxen:** upgraded to 3.0.0-alpha.10
|
|
26
|
+
|
|
1
27
|
## @visulima/error-handler [2.0.0-alpha.11](https://github.com/visulima/visulima/compare/@visulima/error-handler@2.0.0-alpha.10...@visulima/error-handler@2.0.0-alpha.11) (2026-04-08)
|
|
2
28
|
|
|
3
29
|
### Bug Fixes
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
type HtmlErrorHandlerOptions = {
|
|
4
|
+
cspNonce?: string;
|
|
5
|
+
errorPage?: string | ((parameters: {
|
|
6
|
+
error: Error;
|
|
7
|
+
reasonPhrase: string;
|
|
8
|
+
request: IncomingMessage;
|
|
9
|
+
response: ServerResponse;
|
|
10
|
+
statusCode: number;
|
|
11
|
+
}) => string | Promise<string>);
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
declare const htmlErrorHandler: (options?: HtmlErrorHandlerOptions) => ErrorHandler;
|
|
14
|
+
export { HtmlErrorHandlerOptions, htmlErrorHandler };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
type JsonErrorBody = Record<string, unknown> | unknown[];
|
|
4
|
+
type JsonErrorFormatter = (parameters: {
|
|
5
|
+
error: Error;
|
|
6
|
+
reasonPhrase: string;
|
|
7
|
+
request: IncomingMessage;
|
|
8
|
+
response: ServerResponse;
|
|
9
|
+
statusCode: number;
|
|
10
10
|
}) => JsonErrorBody | Promise<JsonErrorBody>;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
type JsonErrorHandlerOptions = {
|
|
12
|
+
formatter?: JsonErrorFormatter;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
declare const jsonErrorHandler: (options?: JsonErrorHandlerOptions) => ErrorHandler;
|
|
15
|
+
export { JsonErrorBody, JsonErrorFormatter, JsonErrorHandlerOptions, jsonErrorHandler };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
2
|
+
import 'node:http';
|
|
2
3
|
declare const jsonapiErrorHandler: ErrorHandler;
|
|
3
|
-
export default
|
|
4
|
+
export { jsonapiErrorHandler as default };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
3
3
|
declare const jsonpErrorHandler: (options?: JsonpErrorHandlerOptions) => ErrorHandler;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
type JsonpErrorBody = Record<string, unknown> | unknown[];
|
|
5
|
+
type JsonpErrorFormatter = (parameters: {
|
|
6
|
+
error: Error;
|
|
7
|
+
reasonPhrase: string;
|
|
8
|
+
request: IncomingMessage;
|
|
9
|
+
response: ServerResponse;
|
|
10
|
+
statusCode: number;
|
|
11
11
|
}) => JsonpErrorBody | Promise<JsonpErrorBody>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type JsonpErrorHandlerOptions = {
|
|
13
|
+
callbackParamName?: string;
|
|
14
|
+
formatter?: JsonpErrorFormatter;
|
|
15
15
|
};
|
|
16
|
-
export { jsonpErrorHandler };
|
|
16
|
+
export { JsonpErrorBody, JsonpErrorFormatter, JsonpErrorHandlerOptions, jsonpErrorHandler };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
* Normalizes errors according to the API Problem spec (RFC 7807).
|
|
4
|
-
* @see https://tools.ietf.org/html/rfc7807
|
|
5
|
-
*/
|
|
1
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
2
|
+
import 'node:http';
|
|
6
3
|
declare const problemErrorHandler: ErrorHandler;
|
|
7
|
-
export default
|
|
4
|
+
export { problemErrorHandler as default };
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
type TextErrorFormatter = (parameters: {
|
|
4
|
+
error: Error;
|
|
5
|
+
reasonPhrase: string;
|
|
6
|
+
request: IncomingMessage;
|
|
7
|
+
response: ServerResponse;
|
|
8
|
+
statusCode: number;
|
|
9
9
|
}) => string | Promise<string>;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type TextErrorHandlerOptions = {
|
|
11
|
+
formatter?: TextErrorFormatter;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
declare const textErrorHandler: (options?: TextErrorHandlerOptions) => ErrorHandler;
|
|
14
|
+
export { TextErrorFormatter, TextErrorHandlerOptions, textErrorHandler };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { a as ErrorHandler } from "../packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
type XmlErrorBody = Record<string, unknown> | unknown[];
|
|
4
|
+
type XmlErrorFormatter = (parameters: {
|
|
5
|
+
error: Error;
|
|
6
|
+
reasonPhrase: string;
|
|
7
|
+
request: IncomingMessage;
|
|
8
|
+
response: ServerResponse;
|
|
9
|
+
statusCode: number;
|
|
10
10
|
}) => XmlErrorBody | Promise<XmlErrorBody>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
type ToXmlOptions = {
|
|
12
|
+
attributeExplicitTrue?: boolean;
|
|
13
|
+
attributeFilter?: (key: string, value: unknown) => boolean;
|
|
14
|
+
attributeReplacements?: Record<string, string>;
|
|
15
|
+
contentMap?: (content: string) => string;
|
|
16
|
+
contentReplacements?: Record<string, string>;
|
|
17
|
+
header?: string | boolean;
|
|
18
|
+
indent?: string;
|
|
19
|
+
selfCloseTags?: boolean;
|
|
20
20
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
type XmlErrorHandlerOptions = {
|
|
22
|
+
formatter?: XmlErrorFormatter;
|
|
23
|
+
toXml?: ToXmlOptions;
|
|
24
|
+
xmlHeader?: boolean;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
declare const xmlErrorHandler: (options?: XmlErrorHandlerOptions) => ErrorHandler;
|
|
27
|
+
export { ToXmlOptions, XmlErrorBody, XmlErrorFormatter, XmlErrorHandlerOptions, xmlErrorHandler };
|
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { RenderErrorOptions } from '@visulima/error/error';
|
|
2
|
+
import { SolutionFinder } from '@visulima/error/solution';
|
|
3
|
+
type CliLogger = {
|
|
4
|
+
error: (...arguments_: unknown[]) => void;
|
|
5
|
+
log: (...arguments_: unknown[]) => void;
|
|
6
|
+
};
|
|
7
|
+
type ColorizeMethod = (value: string) => string;
|
|
8
|
+
type BaseCliOptions = {
|
|
9
|
+
solutionTitle?: string;
|
|
10
|
+
solutionFinders?: SolutionFinder[];
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
} & Partial<Omit<RenderErrorOptions, "color">> & {
|
|
13
|
+
color?: {
|
|
14
|
+
codeFrame?: RenderErrorOptions["color"];
|
|
15
|
+
boxen?: {
|
|
16
|
+
headerTextColor?: ColorizeMethod;
|
|
17
|
+
textColor?: ColorizeMethod;
|
|
18
|
+
borderColor?: ColorizeMethod;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type CliHandlerOptions = BaseCliOptions & {
|
|
23
|
+
logger?: CliLogger;
|
|
24
|
+
};
|
|
25
|
+
declare const terminalOutput: (error: Error, options?: CliHandlerOptions) => Promise<void>;
|
|
26
|
+
declare const ansiHandler: (error: Error, options?: BaseCliOptions) => Promise<string>;
|
|
27
|
+
export { type BaseCliOptions, type CliHandlerOptions, ansiHandler, terminalOutput as cliHandler };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { HtmlErrorHandlerOptions } from "../../error-handler/html-error-handler.js";
|
|
2
|
+
import { F as FetchErrorHandlers } from "../../packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
import 'node:http';
|
|
3
4
|
declare const fetchHandler: (error: Error, options?: HtmlErrorHandlerOptions & {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}) => (request: Request) => Promise<Response
|
|
8
|
-
export default
|
|
5
|
+
extraHandlers?: FetchErrorHandlers;
|
|
6
|
+
onError?: (error: Error, request: Request) => void | Promise<void>;
|
|
7
|
+
showTrace?: boolean;
|
|
8
|
+
}) => ((request: Request) => Promise<Response>);
|
|
9
|
+
export { fetchHandler as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { HtmlErrorHandlerOptions } from "../../error-handler/html-error-handler.js";
|
|
3
|
+
import { E as ErrorHandlers } from "../../packem_shared/types.d-C763gSYq.js";
|
|
4
4
|
declare const nodeHandler: (error: Error, options?: HtmlErrorHandlerOptions & {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}) => (request: IncomingMessage, response: ServerResponse) => Promise<void
|
|
9
|
-
export default
|
|
5
|
+
extraHandlers?: ErrorHandlers;
|
|
6
|
+
onError?: (error: Error, request: IncomingMessage, response: ServerResponse) => void | Promise<void>;
|
|
7
|
+
showTrace?: boolean;
|
|
8
|
+
}) => ((request: IncomingMessage, response: ServerResponse) => Promise<void>);
|
|
9
|
+
export { nodeHandler as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export { jsonErrorHandler } from "./error-handler/json-error-handler.
|
|
6
|
-
export { default as jsonapiErrorHandler } from "./error-handler/jsonapi-error-handler.
|
|
7
|
-
export type
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
export type { ToXmlOptions, XmlErrorBody, XmlErrorFormatter, XmlErrorHandlerOptions } from "./error-handler/xml-error-handler.d.ts";
|
|
14
|
-
export { xmlErrorHandler } from "./error-handler/xml-error-handler.d.ts";
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { E as ErrorHandlers, a as ErrorHandler } from "./packem_shared/types.d-C763gSYq.js";
|
|
3
|
+
export { type A as ApiFormat } from "./packem_shared/types.d-C763gSYq.js";
|
|
4
|
+
export { type HtmlErrorHandlerOptions, htmlErrorHandler } from "./error-handler/html-error-handler.js";
|
|
5
|
+
export { type JsonErrorBody, type JsonErrorFormatter, type JsonErrorHandlerOptions, jsonErrorHandler } from "./error-handler/json-error-handler.js";
|
|
6
|
+
export { default as jsonapiErrorHandler } from "./error-handler/jsonapi-error-handler.js";
|
|
7
|
+
export { type JsonpErrorBody, type JsonpErrorFormatter, type JsonpErrorHandlerOptions, jsonpErrorHandler } from "./error-handler/jsonp-error-handler.js";
|
|
8
|
+
export { default as problemErrorHandler } from "./error-handler/problem-error-handler.js";
|
|
9
|
+
export { type TextErrorFormatter, type TextErrorHandlerOptions, textErrorHandler } from "./error-handler/text-error-handler.js";
|
|
10
|
+
export { type ToXmlOptions, type XmlErrorBody, type XmlErrorFormatter, type XmlErrorHandlerOptions, xmlErrorHandler } from "./error-handler/xml-error-handler.js";
|
|
11
|
+
declare const createNegotiatedErrorHandler: (errorHandlers: ErrorHandlers, showTrace: boolean, defaultHtmlHandler?: ErrorHandler) => (error: Error, request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
12
|
+
export { type ErrorHandler, type ErrorHandlers, createNegotiatedErrorHandler };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
type ErrorHandler = (error: Error, request: IncomingMessage, response: ServerResponse) => Promise<void> | void;
|
|
3
|
+
type FetchErrorHandler = (error: unknown, request: Request) => Promise<Response>;
|
|
4
|
+
type ErrorHandlers = {
|
|
5
|
+
handler: ErrorHandler;
|
|
6
|
+
regex: RegExp;
|
|
7
|
+
}[];
|
|
8
|
+
type FetchErrorHandlers = {
|
|
9
|
+
handler: FetchErrorHandler;
|
|
10
|
+
regex: RegExp;
|
|
11
|
+
}[];
|
|
12
|
+
type ApiFormat = "jsonapi" | "problem" | "html";
|
|
13
|
+
export { ApiFormat as A, ErrorHandlers as E, FetchErrorHandlers as F, ErrorHandler as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/error-handler",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.12",
|
|
4
4
|
"description": "Error handlers for use in development and production environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -134,15 +134,15 @@
|
|
|
134
134
|
],
|
|
135
135
|
"dependencies": {
|
|
136
136
|
"@tinyhttp/accepts": "^2.3.0",
|
|
137
|
-
"@visulima/boxen": "3.0.0-alpha.
|
|
138
|
-
"@visulima/error": "6.0.0-alpha.
|
|
137
|
+
"@visulima/boxen": "3.0.0-alpha.10",
|
|
138
|
+
"@visulima/error": "6.0.0-alpha.13",
|
|
139
139
|
"http-errors": "^2.0.1",
|
|
140
140
|
"http-status-codes": "^2.3.0",
|
|
141
141
|
"jstoxml": "^7.1.0",
|
|
142
142
|
"ts-japi": "^1.12.3"
|
|
143
143
|
},
|
|
144
144
|
"engines": {
|
|
145
|
-
"node": "
|
|
145
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
146
146
|
},
|
|
147
147
|
"publishConfig": {
|
|
148
148
|
"access": "public",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
import type { ErrorHandler, ErrorHandlers } from "./types.d.d.ts";
|
|
3
|
-
declare const createNegotiatedErrorHandler: (errorHandlers: ErrorHandlers, showTrace: boolean, defaultHtmlHandler?: ErrorHandler) => (error: Error, request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
4
|
-
export default createNegotiatedErrorHandler;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { FetchErrorHandlers } from "./types.d.d.ts";
|
|
2
|
-
declare const createFetchNegotiatedErrorHandler: (errorHandlers: FetchErrorHandlers, showTrace: boolean, defaultHtmlHandler?: (error: Error, request: Request) => Promise<Response>) => (error: Error, request: Request) => Promise<Response>;
|
|
3
|
-
export default createFetchNegotiatedErrorHandler;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ServerResponse } from "node:http";
|
|
2
|
-
/**
|
|
3
|
-
* Sends a JSON object as the response body.
|
|
4
|
-
* @param response response object
|
|
5
|
-
* @param jsonBody of data
|
|
6
|
-
* @param contentType optional content-type header value
|
|
7
|
-
*/
|
|
8
|
-
declare const sendJson: (response: ServerResponse, jsonBody: unknown, contentType?: string) => void;
|
|
9
|
-
export default sendJson;
|