@visulima/error-handler 2.0.0 → 2.0.1
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 +7 -0
- package/LICENSE.md +14 -17
- package/dist/error-handler/html-error-handler.d.ts +17 -29
- package/dist/error-handler/html-error-handler.js +5 -5
- package/dist/error-handler/json-error-handler.js +1 -1
- package/dist/error-handler/jsonapi-error-handler.js +1 -1
- package/dist/error-handler/jsonp-error-handler.js +1 -1
- package/dist/error-handler/problem-error-handler.d.ts +3 -3
- package/dist/error-handler/problem-error-handler.js +1 -1
- package/dist/error-handler/text-error-handler.js +2 -2
- package/dist/error-handler/xml-error-handler.js +1 -1
- package/dist/handler/cli-handler.js +1 -1
- package/dist/handler/http/create-error-middleware.d.ts +19 -18
- package/dist/handler/http/create-error-middleware.js +1 -1
- package/dist/handler/http/fetch-handler.js +1 -1
- package/dist/handler/http/node-handler.js +1 -1
- package/dist/index.js +1 -1
- package/dist/packem_shared/{cliHandler-BGq-ckC0.js → cliHandler-SiB_2eYh.js} +25 -25
- package/dist/packem_shared/createNegotiatedErrorHandler-B5QZvIsI.js +1 -0
- package/dist/packem_shared/fetchCreateNegotiatedErrorHandler-BZIDeXwJ.js +1 -0
- package/dist/packem_shared/fetchHtmlErrorHandler-C_tTx5yo.js +1 -0
- package/dist/packem_shared/get-file-source-DizRP9BY.js +1 -0
- package/dist/packem_shared/mock-server-response-B0aq8b_2.js +1 -0
- package/dist/packem_shared/safe-reason-phrase-DgnEIVUq.js +1 -0
- package/dist/packem_shared/with-expose-B0GLDHH8.js +1 -0
- package/package.json +17 -17
- package/dist/packem_shared/add-status-code-to-response-DwELM1q2.js +0 -1
- package/dist/packem_shared/createNegotiatedErrorHandler-CcWOSpO5.js +0 -1
- package/dist/packem_shared/fetchCreateNegotiatedErrorHandler-D9YQ8pOH.js +0 -1
- package/dist/packem_shared/fetchHtmlErrorHandler-Cu50Zu5a.js +0 -1
- package/dist/packem_shared/get-file-source-By3_8e1o.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## @visulima/error-handler [2.0.1](https://github.com/visulima/visulima/compare/%40visulima%2Ferror-handler%402.0.0...%40visulima%2Ferror-handler%402.0.1) (2026-08-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Dependencies
|
|
5
|
+
|
|
6
|
+
* **@visulima/error:** upgraded to 6.1.0
|
|
7
|
+
|
|
1
8
|
## @visulima/error-handler [2.0.0](https://github.com/visulima/visulima/compare/@visulima/error-handler@1.0.13...@visulima/error-handler@2.0.0) (2026-07-03)
|
|
2
9
|
|
|
3
10
|
### ⚠ BREAKING CHANGES
|
package/LICENSE.md
CHANGED
|
@@ -100,6 +100,20 @@ Repository: https://github.com/visulima/visulima.git
|
|
|
100
100
|
>
|
|
101
101
|
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
102
102
|
>
|
|
103
|
+
> ---
|
|
104
|
+
>
|
|
105
|
+
> File: src/vendor/terminal-size/index.ts
|
|
106
|
+
>
|
|
107
|
+
> MIT License
|
|
108
|
+
>
|
|
109
|
+
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
110
|
+
>
|
|
111
|
+
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
112
|
+
>
|
|
113
|
+
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
114
|
+
>
|
|
115
|
+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
116
|
+
>
|
|
103
117
|
>
|
|
104
118
|
>
|
|
105
119
|
> # Licenses of bundled dependencies
|
|
@@ -742,23 +756,6 @@ Repository: https://github.com/visulima/visulima.git
|
|
|
742
756
|
> > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
743
757
|
> > >
|
|
744
758
|
> > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
745
|
-
>
|
|
746
|
-
> ---------------------------------------
|
|
747
|
-
>
|
|
748
|
-
> ## terminal-size
|
|
749
|
-
> License: MIT
|
|
750
|
-
> By: Sindre Sorhus
|
|
751
|
-
> Repository: sindresorhus/terminal-size
|
|
752
|
-
>
|
|
753
|
-
> > MIT License
|
|
754
|
-
> >
|
|
755
|
-
> > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
756
|
-
> >
|
|
757
|
-
> > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
758
|
-
> >
|
|
759
|
-
> > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
760
|
-
> >
|
|
761
|
-
> > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
762
759
|
|
|
763
760
|
<!-- /DEPENDENCIES -->
|
|
764
761
|
|
|
@@ -2,45 +2,33 @@ import { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
2
2
|
import { E as ErrorHandler } from "../packem_shared/types.d-Btzbxdod.js";
|
|
3
3
|
import { SolutionFinder } from '@visulima/error/solution';
|
|
4
4
|
/**
|
|
5
|
-
* Options that influence how the development HTML error inspector is rendered.
|
|
6
|
-
*/
|
|
5
|
+
* Options that influence how the development HTML error inspector is rendered.
|
|
6
|
+
*/
|
|
7
7
|
type HtmlErrorInspectorOptions = {
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
* Permit the underlying code-frame reader to fetch `http(s):`/`data:`
|
|
10
|
+
* stack-frame URLs over the network. Off by default to avoid an SSRF
|
|
11
|
+
* surface; only enable when frame URLs are known to be trusted.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
14
|
allowRemoteSources?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
* Number of source lines rendered above the offending line in the code frame.
|
|
17
|
+
* @default 4
|
|
18
|
+
*/
|
|
19
19
|
linesAbove?: number;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
* Number of source lines rendered below the offending line in the code frame.
|
|
22
|
+
* @default 4
|
|
23
|
+
*/
|
|
24
24
|
linesBelow?: number;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
* Extra solution finders to run before the built-in rule-based and
|
|
27
|
+
* error-hint finders. The first finder (sorted by descending priority)
|
|
28
|
+
* that returns a hint wins. Matches the CLI handler's behaviour.
|
|
29
|
+
*/
|
|
30
30
|
solutionFinders?: SolutionFinder[];
|
|
31
31
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Builds the inner HTML for the development error inspector: error name +
|
|
34
|
-
* message, a syntax-free code frame for the offending source line, the parsed
|
|
35
|
-
* stack trace (one entry per cause), and a possible-solution hint.
|
|
36
|
-
*
|
|
37
|
-
* All dynamic content is HTML-escaped. This is intended for development output
|
|
38
|
-
* only — callers must keep it off the production path so stack/source are not
|
|
39
|
-
* leaked.
|
|
40
|
-
* @param error The error to render.
|
|
41
|
-
* @param options Inspector rendering options.
|
|
42
|
-
* @returns The escaped inner HTML for the inspector.
|
|
43
|
-
*/
|
|
44
32
|
declare const htmlErrorHandler: (options?: HtmlErrorHandlerOptions) => ErrorHandler;
|
|
45
33
|
type HtmlErrorHandlerOptions = HtmlErrorInspectorOptions & {
|
|
46
34
|
cspNonce?: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as h,n as u}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{codeFrame as v}from"@visulima/error/code-frame";import{getErrorCauses as w}from"@visulima/error/error";import{ruleBasedFinder as k,errorHintFinder as S}from"@visulima/error/solution";import{parseStacktrace as $}from"@visulima/error/stacktrace";import{h as j,a as C}from"../packem_shared/get-file-source-DizRP9BY.js";const A=/^\s*#+\s*/,l=e=>e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"),z=e=>e.replace(A,"").trim(),M=async(e,r,t,o)=>{const n=[...r,k,S].toSorted((i,s)=>i.priority-s.priority);for(const i of n){if(typeof i.handle!="function")continue;const s=await i.handle(e,{file:t.file??"",language:C(t.file??""),line:t.line??0,snippet:o});if(s)return s}},N=e=>{if(!e.file)return l(e.raw);let r=l(e.file);return e.line!==void 0&&(r+=`:${String(e.line)}`,e.column!==void 0&&(r+=`:${String(e.column)}`)),r},E=e=>{if(e.length===0)return"";const r=e.map(t=>{const o=l(t.methodName??"<anonymous>"),n=N(t);return String.raw`<li class="vis-frame"><span class="vis-frame-method">${o}</span><span class="vis-frame-loc">${n}</span></li>`}).join("");return String.raw`<ol class="vis-frames">${r}</ol>`},B=e=>{if(!e)return"";const r=l(z(e.header??"A possible solution to this error")),t=l(e.body);return String.raw`
|
|
2
2
|
<section class="vis-card vis-solution">
|
|
3
3
|
<h2 class="vis-card-title">💡 ${r}</h2>
|
|
4
4
|
<pre class="vis-solution-body">${t}</pre>
|
|
5
|
-
</section>`},F=async(e,r={})=>{const{allowRemoteSources:t=!1,linesAbove:o=4,linesBelow:n=4,solutionFinders:i=[]}=r,s=w(e)[0]??e,c=$(s),a=c.find(d=>!!d.file)??c[0]??{};let m="",g="";if(a.file&&a.line!==void 0){const d=await j(a.file,{allowRemote:t});if(d){g=d;const
|
|
5
|
+
</section>`},F=async(e,r={})=>{const{allowRemoteSources:t=!1,linesAbove:o=4,linesBelow:n=4,solutionFinders:i=[]}=r,s=w(e)[0]??e,c=$(s),a=c.find(d=>!!d.file)??c[0]??{};let m="",g="";if(a.file&&a.line!==void 0){const d=await j(a.file,{allowRemote:t});if(d){g=d;const x=v(d,{start:{column:a.column,line:a.line}},{linesAbove:o,linesBelow:n});m=String.raw`
|
|
6
6
|
<section class="vis-card">
|
|
7
7
|
<h2 class="vis-card-title">${l(`${a.file}:${String(a.line)}`)}</h2>
|
|
8
|
-
<pre class="vis-codeframe"><code>${l(
|
|
8
|
+
<pre class="vis-codeframe"><code>${l(x)}</code></pre>
|
|
9
9
|
</section>`}}const p=await M(e,i,a,g),f=l(e.name||"Error"),b=l(e.message||""),y=c.length>0?String.raw`
|
|
10
10
|
<section class="vis-card">
|
|
11
11
|
<h2 class="vis-card-title">Stack trace</h2>
|
|
@@ -36,7 +36,7 @@ import{getReasonPhrase as x}from"http-status-codes";import{a as u}from"../packem
|
|
|
36
36
|
.vis-error-message, .vis-codeframe, .vis-solution-body, .vis-frame-method { color: #e2e8f0; }
|
|
37
37
|
.vis-frame { border-bottom-color: #4a5568; }
|
|
38
38
|
.vis-frame-loc { color: #a0aec0; }
|
|
39
|
-
}`,
|
|
39
|
+
}`,q=(e={})=>async(r,t,o)=>{h(o,r),o.setHeader("content-type","text/html; charset=utf-8");const n=u(o.statusCode,"Error"),i=e.cspNonce?` nonce="${e.cspNonce}"`:"";if(e.errorPage){const a=typeof e.errorPage=="function"?await e.errorPage({error:r,reasonPhrase:n,request:t,response:o,statusCode:o.statusCode}):e.errorPage;if(a){o.end(a);return}}const{expose:s}=r,c=s?await F(r,{allowRemoteSources:e.allowRemoteSources,linesAbove:e.linesAbove,linesBelow:e.linesBelow,solutionFinders:e.solutionFinders}):"";o.end(String.raw`<!DOCTYPE html>
|
|
40
40
|
<html lang="en">
|
|
41
41
|
<head>
|
|
42
42
|
<meta charset="utf-8">
|
|
@@ -72,4 +72,4 @@ import{getReasonPhrase as x}from"http-status-codes";import{a as u}from"../packem
|
|
|
72
72
|
</div>
|
|
73
73
|
</div>${c}
|
|
74
74
|
</body>
|
|
75
|
-
</html>`)};export{
|
|
75
|
+
</html>`)};export{q as htmlErrorHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as p,n as f}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{o as a}from"../packem_shared/send-json-fz8r6NBW.js";import{o as i}from"../packem_shared/set-error-headers-g9hns3cZ.js";const g=(o={})=>async(s,m,e)=>{p(e,s),i(e,s);const{statusCode:r}=e,t=f(r);if(o.formatter){const c=await o.formatter({error:s,reasonPhrase:t,request:m,response:e,statusCode:r});a(e,c);return}const{expose:n}=s;a(e,{message:s.message||t,error:t,statusCode:r,...n?{stack:s.stack}:{}})};export{g as jsonErrorHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isHttpError as
|
|
1
|
+
import{isHttpError as n}from"http-errors";import t from"ts-japi";import{a as f,n as m}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import l from"../packem_shared/extractStatusCode-D0UOgNnr.js";import{o as s}from"../packem_shared/send-json-fz8r6NBW.js";import{o as c}from"../packem_shared/set-error-headers-g9hns3cZ.js";const a="application/vnd.api+json; charset=utf-8",y=(r,d,e)=>{if(f(e,r),c(e,r),r instanceof t.JapiError||t.JapiError.isLikeJapiError(r)){const i=new t.ErrorSerializer;s(e,i.serialize(r),a)}else if(n(r)){const i=l(r,e.statusCode),o="title"in r&&typeof r.title=="string"?r.title:void 0,p="message"in r&&typeof r.message=="string"?r.message:"";s(e,{errors:[{code:i,title:o??m(i),detail:p}]},a)}else{const{message:i}=r,{statusCode:o}=e;s(e,{errors:[{code:o,title:m(o),detail:i}]},a)}};export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as f,n as d}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{o as h}from"../packem_shared/set-error-headers-g9hns3cZ.js";const c="callback",g=/^[A-Za-z_$][\w$.]*$/u,y=(s={})=>async(e,l,t)=>{f(t,e),h(t,e);const{statusCode:o}=t,r=d(o),p=new URL(l.url??"http://localhost","http://localhost"),i=s.callbackParamName??c;let a=p.searchParams.get(i)??c,n;if(s.formatter)n=await s.formatter({error:e,reasonPhrase:r,request:l,response:t,statusCode:o});else{const{expose:m}=e;n={message:e.message||r,error:r,statusCode:o,...m?{stack:e.stack}:{}}}(a.length>64||!g.test(a))&&(a=c),t.setHeader("content-type","application/javascript; charset=utf-8"),t.setHeader("x-content-type-options","nosniff");const u=JSON.stringify(n).replaceAll("\u2028",String.raw`\u2028`).replaceAll("\u2029",String.raw`\u2029`);t.end(`/**/ typeof ${a} === 'function' && ${a}(${u});`)};export{y as jsonpErrorHandler};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { E as ErrorHandler } from "../packem_shared/types.d-Btzbxdod.js";
|
|
2
2
|
import 'node:http';
|
|
3
3
|
/**
|
|
4
|
-
* Normalizes errors according to the API Problem spec (RFC 7807).
|
|
5
|
-
* @see https://tools.ietf.org/html/rfc7807
|
|
6
|
-
*/
|
|
4
|
+
* Normalizes errors according to the API Problem spec (RFC 7807).
|
|
5
|
+
* @see https://tools.ietf.org/html/rfc7807
|
|
6
|
+
*/
|
|
7
7
|
declare const problemErrorHandler: ErrorHandler;
|
|
8
8
|
export { problemErrorHandler as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isHttpError as d}from"http-errors";import{
|
|
1
|
+
import{isHttpError as d}from"http-errors";import{a,n as p}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{o as r}from"../packem_shared/send-json-fz8r6NBW.js";import{o as f}from"../packem_shared/set-error-headers-g9hns3cZ.js";const l="about:blank",v=(o,y,t)=>{const{message:s,stack:e}=o;if(d(o)){const n="expose"in o?o.expose:void 0,m="title"in o&&typeof o.title=="string"?o.title:void 0,c="type"in o&&typeof o.type=="string"?o.type:void 0;a(t,o);const{statusCode:i}=t;f(t,o),r(t,{type:c??l,title:m??p(i),status:i,detail:s,...n?{trace:e}:{}},"application/problem+json")}else a(t,o),r(t,{type:l,title:p(t.statusCode),status:t.statusCode,detail:s,...o.expose?{trace:e}:{}},"application/problem+json")};export{v as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as i,n as m}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{o as f}from"../packem_shared/set-error-headers-g9hns3cZ.js";const x=(o={})=>async(e,c,t)=>{i(t,e),f(t,e);const{statusCode:r}=t,s=m(r,"Error");if(t.setHeader("content-type","text/plain; charset=utf-8"),o.formatter){const d=await o.formatter({error:e,reasonPhrase:s,request:c,response:t,statusCode:r});t.end(d);return}const a=e.message||s,{expose:p}=e,n=p?e.stack:void 0;t.end(n?`${a}
|
|
2
2
|
|
|
3
|
-
${n}`:a)};export{
|
|
3
|
+
${n}`:a)};export{x as textErrorHandler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{toXML as i}from"jstoxml";import{a as c,n as p}from"../packem_shared/safe-reason-phrase-DgnEIVUq.js";import{o as u}from"../packem_shared/set-error-headers-g9hns3cZ.js";const b=(t={})=>async(e,l,o)=>{c(o,e),u(o,e);const{statusCode:a}=o,s=p(a);let r;if(t.formatter)r=await t.formatter({error:e,reasonPhrase:s,request:l,response:o,statusCode:a});else{const{expose:m}=e;r={error:{statusCode:a,name:s,message:e.message||s,...m?{stack:e.stack}:{}}}}const n=i(r,{header:t.toXml?.header??t.xmlHeader??!0,indent:t.toXml?.indent??" ",...t.toXml?.attributeReplacements?{attributeReplacements:t.toXml.attributeReplacements}:{},...t.toXml?.attributeFilter?{attributeFilter:t.toXml.attributeFilter}:{},...t.toXml?.attributeExplicitTrue===void 0?{}:{attributeExplicitTrue:t.toXml.attributeExplicitTrue},...t.toXml?.contentMap?{contentMap:t.toXml.contentMap}:{},...t.toXml?.contentReplacements?{contentReplacements:t.toXml.contentReplacements}:{},...t.toXml?.selfCloseTags===void 0?{}:{selfCloseTags:t.toXml.selfCloseTags}});o.setHeader("content-type","application/xml; charset=utf-8"),o.end(n)};export{b as xmlErrorHandler};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{buildOutput as n}from"../packem_shared/cliHandler-
|
|
1
|
+
import{buildOutput as n}from"../packem_shared/cliHandler-SiB_2eYh.js";import{terminalOutput as l}from"../packem_shared/cliHandler-SiB_2eYh.js";const e=async(o,i={})=>{const{errorAnsi:r,solutionBox:t}=await n(o,i);return t===void 0?r:`${r}
|
|
2
2
|
|
|
3
3
|
${t}`};export{e as ansiHandler,l as cliHandler};
|
|
@@ -3,29 +3,30 @@ import { HtmlErrorHandlerOptions } from "../../error-handler/html-error-handler.
|
|
|
3
3
|
import { a as ErrorHandlers } from "../../packem_shared/types.d-Btzbxdod.js";
|
|
4
4
|
import '@visulima/error/solution';
|
|
5
5
|
type ErrorMiddlewareOptions = HtmlErrorHandlerOptions & {
|
|
6
|
-
extraHandlers?: ErrorHandlers;
|
|
6
|
+
extraHandlers?: ErrorHandlers;
|
|
7
|
+
/** Callback to handle error logging. */
|
|
7
8
|
onError?: (error: Error, request: IncomingMessage, response: ServerResponse) => void | Promise<void>;
|
|
8
9
|
/** Include stack traces in responses. Defaults to `NODE_ENV !== "production"`. */
|
|
9
10
|
showTrace?: boolean;
|
|
10
11
|
};
|
|
11
12
|
type ErrorMiddleware = (error: Error, request: IncomingMessage, response: ServerResponse, next?: (error?: unknown) => void) => Promise<void>;
|
|
12
13
|
/**
|
|
13
|
-
* Express/Connect-style error middleware.
|
|
14
|
-
*
|
|
15
|
-
* Unlike {@link nodeHandler}, which takes the error at construction time and so
|
|
16
|
-
* has to be rebuilt inside every `catch` block, this returns a four-argument
|
|
17
|
-
* error middleware you register once:
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { createErrorMiddleware } from "@visulima/error-handler";
|
|
21
|
-
*
|
|
22
|
-
* app.use(createErrorMiddleware({ showTrace: "production" !== "production" }));
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* The returned function matches the Express/Connect `(err, req, res, next)`
|
|
26
|
-
* signature. If the response has already started streaming
|
|
27
|
-
* (`response.headersSent`), it delegates to `next(error)` so the framework's
|
|
28
|
-
* default handler can close the connection rather than double-writing.
|
|
29
|
-
*/
|
|
14
|
+
* Express/Connect-style error middleware.
|
|
15
|
+
*
|
|
16
|
+
* Unlike {@link nodeHandler}, which takes the error at construction time and so
|
|
17
|
+
* has to be rebuilt inside every `catch` block, this returns a four-argument
|
|
18
|
+
* error middleware you register once:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createErrorMiddleware } from "@visulima/error-handler";
|
|
22
|
+
*
|
|
23
|
+
* app.use(createErrorMiddleware({ showTrace: "production" !== "production" }));
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* The returned function matches the Express/Connect `(err, req, res, next)`
|
|
27
|
+
* signature. If the response has already started streaming
|
|
28
|
+
* (`response.headersSent`), it delegates to `next(error)` so the framework's
|
|
29
|
+
* default handler can close the connection rather than double-writing.
|
|
30
|
+
*/
|
|
30
31
|
declare const createErrorMiddleware: (options?: ErrorMiddlewareOptions) => ErrorMiddleware;
|
|
31
32
|
export { type ErrorMiddleware, type ErrorMiddlewareOptions, createErrorMiddleware as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"./node-handler.js";const
|
|
1
|
+
import n from"./node-handler.js";const c=(r={})=>async(t,i,a,e)=>{if(a.headersSent){e&&e(t);return}await n(t,r)(i,a)};export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import l from"../../packem_shared/fetchCreateNegotiatedErrorHandler-BZIDeXwJ.js";import i from"../../packem_shared/fetchHtmlErrorHandler-C_tTx5yo.js";const d=(o,r={})=>{const e=i(r),t=globalThis.process?.env,n=r.showTrace??(t===void 0?!1:t.NODE_ENV!=="production"),s=l(r.extraHandlers??[],n,e);return async a=>{if(r.onError)try{await r.onError(o,a)}catch(c){console.error(c)}return s(o,a)}};export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import i from"../../packem_shared/createNegotiatedErrorHandler-B5QZvIsI.js";import{htmlErrorHandler as d}from"../../error-handler/html-error-handler.js";const p=(r,o={})=>{const c=d(o),a=globalThis.process?.env,n=o.showTrace??(a===void 0?!1:a.NODE_ENV!=="production"),s=i(o.extraHandlers??[],n,c);return async(t,e)=>{if(o.onError)try{await o.onError(r,t,e)}catch(l){console.error(l)}await s(r,t,e)}};export{p as default};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as o}from"./packem_shared/createNegotiatedErrorHandler-
|
|
1
|
+
import{default as o}from"./packem_shared/createNegotiatedErrorHandler-B5QZvIsI.js";import{default as a}from"./packem_shared/fetchCreateNegotiatedErrorHandler-BZIDeXwJ.js";import{default as f}from"./packem_shared/fetchHtmlErrorHandler-C_tTx5yo.js";import{htmlErrorHandler as m}from"./error-handler/html-error-handler.js";import{jsonErrorHandler as p}from"./error-handler/json-error-handler.js";import{default as s}from"./error-handler/jsonapi-error-handler.js";import{jsonpErrorHandler as u}from"./error-handler/jsonp-error-handler.js";import{default as c}from"./error-handler/problem-error-handler.js";import{textErrorHandler as i}from"./error-handler/text-error-handler.js";import{default as g}from"./packem_shared/extractStatusCode-D0UOgNnr.js";import{default as N}from"./packem_shared/sendFetchJson-BNmfrMYp.js";import{xmlErrorHandler as w}from"./error-handler/xml-error-handler.js";import{default as J}from"./handler/http/create-error-middleware.js";import{default as S}from"./handler/http/fetch-handler.js";import{default as q}from"./handler/http/node-handler.js";export{J as createErrorMiddleware,o as createNegotiatedErrorHandler,g as extractStatusCode,a as fetchCreateNegotiatedErrorHandler,S as fetchHandler,f as fetchHtmlErrorHandler,m as htmlErrorHandler,p as jsonErrorHandler,s as jsonapiErrorHandler,u as jsonpErrorHandler,q as nodeHandler,c as problemErrorHandler,N as sendFetchJson,i as textErrorHandler,w as xmlErrorHandler};
|