@stacksjs/error-handling 0.72.50 → 0.72.51
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/dist/error-page.js +1 -1
- package/package.json +7 -7
package/dist/error-page.js
CHANGED
|
@@ -19,7 +19,7 @@ var {require}=import.meta;const DOCS_BASE="https://stacksjs.org/docs/errors";exp
|
|
|
19
19
|
</section>
|
|
20
20
|
</main>
|
|
21
21
|
</body>
|
|
22
|
-
</html>`}export function renderHttpErrorHints(status){const info=HTTP_ERRORS[status];if(!info)return"";const hasCauses=Array.isArray(info.commonCauses)&&info.commonCauses.length>0,hasSuggestion=typeof info.suggestion==="string"&&info.suggestion.length>0,hasDoc=typeof info.docLink==="string"&&info.docLink.length>0;if(!hasCauses&&!hasSuggestion&&!hasDoc)return"";const causes=hasCauses?`<ul class="error-hint-causes">${info.commonCauses.map((c)=>`<li>${escapeHtml(c)}</li>`).join("")}</ul>`:"",suggestion=hasSuggestion?`<p class="error-hint-suggestion">${escapeHtml(info.suggestion)}</p>`:"",doc=hasDoc?`<a class="text-
|
|
22
|
+
</html>`}export function renderHttpErrorHints(status){const info=HTTP_ERRORS[status];if(!info)return"";const hasCauses=Array.isArray(info.commonCauses)&&info.commonCauses.length>0,hasSuggestion=typeof info.suggestion==="string"&&info.suggestion.length>0,hasDoc=typeof info.docLink==="string"&&info.docLink.length>0;if(!hasCauses&&!hasSuggestion&&!hasDoc)return"";const causes=hasCauses?`<ul class="error-hint-causes">${info.commonCauses.map((c)=>`<li>${escapeHtml(c)}</li>`).join("")}</ul>`:"",suggestion=hasSuggestion?`<p class="error-hint-suggestion">${escapeHtml(info.suggestion)}</p>`:"",doc=hasDoc?`<a class="text-[#a22a50] text-sm dark:text-[#f0a07e] hover:underline" href="${escapeHtml(info.docLink)}" target="_blank" rel="noreferrer noopener">Read the docs \u2192</a>`:"";return`<section class="p-4 bg-amber-200/30 dark:bg-amber-950/40 border border-amber-200 rounded-xl dark:border-amber-800 shadow-xs">
|
|
23
23
|
<div class="mb-2 font-semibold text-amber-900 text-sm dark:text-amber-300">Likely causes & next steps</div>
|
|
24
24
|
<div class="text-neutral-700 text-sm dark:text-neutral-300">${causes}${suggestion}${doc}</div>
|
|
25
25
|
</section>`}export class ErrorPageHandler{config;framework;request;routing;user;queries=[];constructor(config){this.config={appName:"App",theme:"auto",showEnvironment:!0,showQueries:!0,showRequest:!0,enableCopyMarkdown:!0,snippetLines:8,...config}}setFramework(name,version){this.framework={name,version};return this}setRequest(request){if(request instanceof Request){const url=new URL(request.url);this.request={method:request.method,url:request.url,headers:Object.fromEntries(request.headers.entries()),queryParams:Object.fromEntries(url.searchParams.entries())}}else this.request=request;return this}setRouting(routing){this.routing=routing;return this}setUser(user){this.user=user;return this}addQuery(query,time,connection){this.queries.push({query,time,connection});return this}async render(error,status=500){try{const{renderDevErrorPage}=await import("./error-page-renderer");return await renderDevErrorPage({error,status,config:this.config,framework:this.framework,request:this.request,routing:this.routing,user:this.user,queries:this.queries})}catch(renderError){console.error("[ErrorPageHandler] STX render failed, using fallback:",renderError);return this.renderFallback(error,status)}}renderFallback(error,status){const frames=parseStackTrace(error.stack,this.config.basePaths,{includeFrameworkFrames:this.config.showFrameworkFrames===!0}),statusTitle=HTTP_ERRORS[status]?.title??"Error",topFrame=frames[0],body=`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/error-handling",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.72.
|
|
4
|
+
"version": "0.72.51",
|
|
5
5
|
"description": "Type safe error handling.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"prepublishOnly": "bun run build"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@stacksjs/stx": "^0.2.
|
|
60
|
+
"@stacksjs/stx": "^0.2.219",
|
|
61
61
|
"ts-error-handling": "^0.1.1",
|
|
62
62
|
"ts-syntax-highlighter": "^0.2.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@stacksjs/cli": "0.72.
|
|
66
|
-
"@stacksjs/config": "0.72.
|
|
65
|
+
"@stacksjs/cli": "0.72.51",
|
|
66
|
+
"@stacksjs/config": "0.72.51",
|
|
67
67
|
"better-dx": "^0.2.24",
|
|
68
|
-
"@stacksjs/path": "0.72.
|
|
69
|
-
"@stacksjs/types": "0.72.
|
|
70
|
-
"@stacksjs/validation": "0.72.
|
|
68
|
+
"@stacksjs/path": "0.72.51",
|
|
69
|
+
"@stacksjs/types": "0.72.51",
|
|
70
|
+
"@stacksjs/validation": "0.72.51"
|
|
71
71
|
},
|
|
72
72
|
"sideEffects": false
|
|
73
73
|
}
|