@visulima/error-handler 2.0.0-alpha.33 → 2.0.0-alpha.34
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/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.34",
|
|
4
4
|
"description": "Error handlers for use in development and production environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -140,8 +140,7 @@
|
|
|
140
140
|
],
|
|
141
141
|
"dependencies": {
|
|
142
142
|
"@tinyhttp/accepts": "^2.3.0",
|
|
143
|
-
"@visulima/
|
|
144
|
-
"@visulima/error": "6.0.0-alpha.34",
|
|
143
|
+
"@visulima/error": "6.0.0-alpha.35",
|
|
145
144
|
"http-errors": "^2.0.1",
|
|
146
145
|
"http-status-codes": "^2.3.0",
|
|
147
146
|
"jstoxml": "^7.1.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{parseStacktrace as c}from"@visulima/error/stacktrace";import{boxen as d}from"@visulima/boxen";import{renderError as p}from"@visulima/error/error";import{h as g,a as b}from"./get-file-source-By3_8e1o.js";import{ruleBasedFinder as y,errorHintFinder as h}from"@visulima/error/solution";const x=t=>t.replace(/^\s*#+\s*/,"").trim(),A=async(t,l,r=!1,n)=>{const s=[...l,y,h].sort((a,e)=>a.priority-e.priority),o=c(t,{frameLimit:1})[0]??{},f=o.file?await g(o.file):"";for(const a of s){const{handle:e,name:i}=a;if(r&&(n??console).log(`[solution-finder] running: ${i??"anonymous"}`),typeof e!="function")continue;const u=await e(t,{file:o.file??"",language:b(o.file??""),line:o.line??0,snippet:f});if(u)return r&&(n??console).log(`[solution-finder] matched: ${i??"anonymous"}`),u}},w=async(t,l,r)=>{const{solutionFinders:n=[],solutionTitle:s,color:o,debug:f=!1,...a}=l,e=p(t,{...a,...o?.codeFrame}),i=await A(t,n,f,r);if(!i)return{errorAnsi:e,solutionBox:void 0};const u=x(i.header??s??"A possible solution to this error"),m=d(i.body,{borderStyle:"round",padding:{top:1,right:2,bottom:1,left:2},margin:{top:0,right:0,bottom:0,left:0},headerText:`💡 ${u}`,headerAlignment:"left",textAlignment:"left",...o?.boxen});return{errorAnsi:e,solutionBox:m}},T=async(t,l={})=>{const{logger:r=console,...n}=l,{errorAnsi:s,solutionBox:o}=await w(t,n,r);r.error(s),o&&(r.log(""),r.log(o))};export{w as buildOutput,T as terminalOutput};
|