effect-errors 1.4.4 → 1.4.6
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/cjs/capture-errors.js +11 -8
- package/cjs/capture-errors.js.map +1 -1
- package/cjs/index.js +8 -8
- package/cjs/index.js.map +1 -1
- package/cjs/logic/errors/capture-errors-from-cause.js +1 -1
- package/cjs/logic/errors/parse-error.js +4 -4
- package/cjs/logic/errors/parse-error.js.map +1 -1
- package/cjs/logic/pretty-printing/format-failures-title.js +3 -3
- package/cjs/logic/pretty-printing/format-failures-title.js.map +1 -1
- package/cjs/logic/pretty-printing/format-span-attributes.js +7 -7
- package/cjs/logic/pretty-printing/format-span-attributes.js.map +1 -1
- package/cjs/logic/pretty-printing/maybe-print-node-stacktrace.js +4 -4
- package/cjs/logic/pretty-printing/maybe-print-node-stacktrace.js.map +1 -1
- package/cjs/logic/pretty-printing/maybe-print-span-attributes.js +4 -4
- package/cjs/logic/pretty-printing/maybe-print-span-attributes.js.map +1 -1
- package/cjs/logic/pretty-printing/maybe-warn-about-plain-strings.js +3 -3
- package/cjs/logic/pretty-printing/maybe-warn-about-plain-strings.js.map +1 -1
- package/cjs/logic/pretty-printing/print-effect-stacktrace.js +4 -4
- package/cjs/logic/pretty-printing/print-effect-stacktrace.js.map +1 -1
- package/cjs/logic/spans/get-span-attributes.js +4 -4
- package/cjs/logic/spans/get-span-attributes.js.map +1 -1
- package/cjs/logic/spans/get-span-duration.js +3 -3
- package/cjs/logic/spans/get-span-duration.js.map +1 -1
- package/cjs/logic/spans/spans-stack-trailing-char.js +3 -3
- package/cjs/logic/spans/spans-stack-trailing-char.js.map +1 -1
- package/cjs/logic/stack/filter-stack.js +3 -2
- package/cjs/logic/stack/filter-stack.js.map +1 -1
- package/cjs/logic/stack/stack-regex.js +10 -0
- package/cjs/logic/stack/stack-regex.js.map +1 -0
- package/cjs/pretty-print.js +11 -11
- package/cjs/pretty-print.js.map +1 -1
- package/cjs/runners/run-promise.js +4 -4
- package/cjs/runners/run-promise.js.map +1 -1
- package/cjs/runners/run-sync.js +4 -4
- package/cjs/runners/run-sync.js.map +1 -1
- package/cjs/source-maps/get-source-excerpt.js +46 -0
- package/cjs/source-maps/get-source-excerpt.js.map +1 -0
- package/cjs/source-maps/get-ts-code-from-sourcemap.js +58 -0
- package/cjs/source-maps/get-ts-code-from-sourcemap.js.map +1 -0
- package/cjs/source-maps/insert-into.js +9 -0
- package/cjs/source-maps/insert-into.js.map +1 -0
- package/cjs/source-maps/maybe-map-sourcemaps.js +25 -0
- package/cjs/source-maps/maybe-map-sourcemaps.js.map +1 -0
- package/dts/capture-errors.d.ts +3 -2
- package/dts/capture-errors.d.ts.map +1 -1
- package/dts/index.d.ts +6 -5
- package/dts/index.d.ts.map +1 -1
- package/dts/logic/errors/capture-errors-from-cause.d.ts +1 -1
- package/dts/logic/errors/capture-errors-from-cause.d.ts.map +1 -1
- package/dts/logic/errors/parse-error.d.ts +1 -1
- package/dts/logic/errors/parse-error.d.ts.map +1 -1
- package/dts/logic/pretty-printing/format-span-attributes.d.ts +1 -1
- package/dts/logic/pretty-printing/format-span-attributes.d.ts.map +1 -1
- package/dts/logic/pretty-printing/maybe-print-node-stacktrace.d.ts +1 -1
- package/dts/logic/pretty-printing/maybe-print-node-stacktrace.d.ts.map +1 -1
- package/dts/logic/pretty-printing/maybe-print-span-attributes.d.ts +1 -1
- package/dts/logic/pretty-printing/maybe-print-span-attributes.d.ts.map +1 -1
- package/dts/logic/pretty-printing/print-effect-stacktrace.d.ts +1 -1
- package/dts/logic/pretty-printing/print-effect-stacktrace.d.ts.map +1 -1
- package/dts/logic/stack/filter-stack.d.ts.map +1 -1
- package/dts/logic/stack/stack-regex.d.ts +4 -0
- package/dts/logic/stack/stack-regex.d.ts.map +1 -0
- package/dts/pretty-print.d.ts +1 -1
- package/dts/pretty-print.d.ts.map +1 -1
- package/dts/runners/run-promise.d.ts +1 -1
- package/dts/runners/run-promise.d.ts.map +1 -1
- package/dts/runners/run-sync.d.ts +1 -1
- package/dts/runners/run-sync.d.ts.map +1 -1
- package/dts/source-maps/get-source-excerpt.d.ts +2 -0
- package/dts/source-maps/get-source-excerpt.d.ts.map +1 -0
- package/dts/source-maps/get-ts-code-from-sourcemap.d.ts +6 -0
- package/dts/source-maps/get-ts-code-from-sourcemap.d.ts.map +1 -0
- package/dts/source-maps/insert-into.d.ts +2 -0
- package/dts/source-maps/insert-into.d.ts.map +1 -0
- package/dts/source-maps/maybe-map-sourcemaps.d.ts +3 -0
- package/dts/source-maps/maybe-map-sourcemaps.d.ts.map +1 -0
- package/esm/capture-errors.js +11 -8
- package/esm/capture-errors.js.map +1 -1
- package/esm/index.js +5 -5
- package/esm/index.js.map +1 -1
- package/esm/logic/errors/capture-errors-from-cause.js +1 -1
- package/esm/logic/errors/capture-errors-from-cause.js.map +1 -1
- package/esm/logic/errors/parse-error.js +2 -2
- package/esm/logic/errors/parse-error.js.map +1 -1
- package/esm/logic/pretty-printing/format-span-attributes.js +4 -4
- package/esm/logic/pretty-printing/format-span-attributes.js.map +1 -1
- package/esm/logic/pretty-printing/maybe-print-node-stacktrace.js +1 -1
- package/esm/logic/pretty-printing/maybe-print-node-stacktrace.js.map +1 -1
- package/esm/logic/pretty-printing/maybe-print-span-attributes.js +1 -1
- package/esm/logic/pretty-printing/maybe-print-span-attributes.js.map +1 -1
- package/esm/logic/pretty-printing/print-effect-stacktrace.js +1 -1
- package/esm/logic/pretty-printing/print-effect-stacktrace.js.map +1 -1
- package/esm/logic/spans/get-span-attributes.js +1 -1
- package/esm/logic/spans/get-span-attributes.js.map +1 -1
- package/esm/logic/stack/filter-stack.js +3 -2
- package/esm/logic/stack/filter-stack.js.map +1 -1
- package/esm/logic/stack/stack-regex.js +4 -0
- package/esm/logic/stack/stack-regex.js.map +1 -0
- package/esm/pretty-print.js +7 -7
- package/esm/pretty-print.js.map +1 -1
- package/esm/runners/run-promise.js +2 -2
- package/esm/runners/run-promise.js.map +1 -1
- package/esm/runners/run-sync.js +2 -2
- package/esm/runners/run-sync.js.map +1 -1
- package/esm/source-maps/get-source-excerpt.js +34 -0
- package/esm/source-maps/get-source-excerpt.js.map +1 -0
- package/esm/source-maps/get-ts-code-from-sourcemap.js +46 -0
- package/esm/source-maps/get-ts-code-from-sourcemap.js.map +1 -0
- package/esm/source-maps/insert-into.js +2 -0
- package/esm/source-maps/insert-into.js.map +1 -0
- package/esm/source-maps/maybe-map-sourcemaps.js +18 -0
- package/esm/source-maps/maybe-map-sourcemaps.js.map +1 -0
- package/package.json +10 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import { splitSpansAttributesByTypes } from './split-spans-attributes-by-type';
|
|
2
|
+
import { splitSpansAttributesByTypes } from './split-spans-attributes-by-type.js';
|
|
3
3
|
const maybePrintPipe = isLastEntry => isLastEntry ? ' ' : chalk.gray('│');
|
|
4
4
|
export const getSpanAttributes = (allAttributes, isLastEntry) => {
|
|
5
5
|
if (allAttributes.size === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-span-attributes.js","names":["chalk","splitSpansAttributesByTypes","maybePrintPipe","isLastEntry","gray","getSpanAttributes","allAttributes","size","formattedAttributes","stack","attributes","stacktrace","Array","from","map","key","value","blue","join","length"],"sources":["../../../../src/logic/spans/get-span-attributes.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,2BAA2B,QAAQ,
|
|
1
|
+
{"version":3,"file":"get-span-attributes.js","names":["chalk","splitSpansAttributesByTypes","maybePrintPipe","isLastEntry","gray","getSpanAttributes","allAttributes","size","formattedAttributes","stack","attributes","stacktrace","Array","from","map","key","value","blue","join","length"],"sources":["../../../../src/logic/spans/get-span-attributes.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,2BAA2B,QAAQ,qCAAqC;AAEjF,MAAMC,cAAc,GAAIC,WAAoB,IAC1CA,WAAW,GAAG,GAAG,GAAGH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;AAErC,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,aAA2C,EAC3CH,WAAoB,KAClB;EACF,IAAIG,aAAa,CAACC,IAAI,KAAK,CAAC,EAAE;IAC5B,OAAO;MAAEC,mBAAmB,EAAE,EAAE;MAAEC,KAAK,EAAE;IAAE,CAAE;EAC/C;EAEA,MAAM;IAAEC,UAAU;IAAEC;EAAU,CAAE,GAAGV,2BAA2B,CAACK,aAAa,CAAC;EAE7E,MAAME,mBAAmB,GAAGI,KAAK,CAACC,IAAI,CAACH,UAAU,CAAC,CAC/CI,GAAG,CACF,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KACX,GAAGd,cAAc,CAACC,WAAW,CAAC,QAAQH,KAAK,CAACiB,IAAI,CAACF,GAAG,CAAC,GAAGf,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC,IAAIY,KAAe,EAAE,CAC/F,CACAE,IAAI,CAAC,MAAM,CAAC;EAEf,OAAO;IACLV,mBAAmB,EAAE,GAAGA,mBAAmB,CAACW,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,EAAE,GAAGX,mBAAmB,EAAE;IAC5FC,KAAK,EAAEE;GACR;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { stripCwdPath } from '../strip-cwd-path';
|
|
1
|
+
import { stripCwdPath } from '../strip-cwd-path.js';
|
|
2
|
+
import { stackAtRegex } from './stack-regex.js';
|
|
2
3
|
export const filterStack = (stack, stripCwd) => {
|
|
3
4
|
const lines = stack.split('\r\n');
|
|
4
5
|
const out = [];
|
|
@@ -8,7 +9,7 @@ export const filterStack = (stack, stripCwd) => {
|
|
|
8
9
|
return out.join('\r\n');
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
const final = out.join('\r\n').replace(
|
|
12
|
+
const final = out.join('\r\n').replace(stackAtRegex, '│ at ');
|
|
12
13
|
return stripCwd ? stripCwdPath(final) : final;
|
|
13
14
|
};
|
|
14
15
|
//# sourceMappingURL=filter-stack.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-stack.js","names":["stripCwdPath","filterStack","stack","stripCwd","lines","split","out","line","push","replace","includes","join","final"],"sources":["../../../../src/logic/stack/filter-stack.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,QAAQ,
|
|
1
|
+
{"version":3,"file":"filter-stack.js","names":["stripCwdPath","stackAtRegex","filterStack","stack","stripCwd","lines","split","out","line","push","replace","includes","join","final"],"sources":["../../../../src/logic/stack/filter-stack.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,QAAQ,sBAAsB;AAEnD,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,OAAO,MAAMC,WAAW,GAAGA,CAACC,KAAa,EAAEC,QAAiB,KAAI;EAC9D,MAAMC,KAAK,GAAGF,KAAK,CAACG,KAAK,CAAC,MAAM,CAAC;EACjC,MAAMC,GAAG,GAAa,EAAE;EAExB,KAAK,MAAMC,IAAI,IAAIH,KAAK,EAAE;IACxBE,GAAG,CAACE,IAAI,CAACD,IAAI,CAACE,OAAO,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAEjE,IAAIF,IAAI,CAACG,QAAQ,CAAC,iBAAiB,CAAC,EAAE;MACpC,OAAOJ,GAAG,CAACK,IAAI,CAAC,MAAM,CAAC;IACzB;EACF;EAEA,MAAMC,KAAK,GAAGN,GAAG,CAACK,IAAI,CAAC,MAAM,CAAC,CAACF,OAAO,CAACT,YAAY,EAAE,OAAO,CAAC;EAE7D,OAAOG,QAAQ,GAAGJ,YAAY,CAACa,KAAK,CAAC,GAAGA,KAAK;AAC/C,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-regex.js","names":["stackLineRegex","stackAtRegex","fileRegex"],"sources":["../../../../src/logic/stack/stack-regex.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAG,sBAAsB;AACpD,OAAO,MAAMC,YAAY,GAAG,UAAU;AACtC,OAAO,MAAMC,SAAS,GAAG,UAAU","ignoreList":[]}
|
package/esm/pretty-print.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { isInterruptedOnly } from 'effect/Cause';
|
|
3
|
-
import { captureErrorsFrom } from './logic/errors/capture-errors-from-cause';
|
|
4
|
-
import { formatFailuresTitle } from './logic/pretty-printing/format-failures-title';
|
|
5
|
-
import { maybePrintNodeStacktrace } from './logic/pretty-printing/maybe-print-node-stacktrace';
|
|
6
|
-
import { maybePrintSpanAttributes } from './logic/pretty-printing/maybe-print-span-attributes';
|
|
7
|
-
import { maybeWarnAboutPlainStrings } from './logic/pretty-printing/maybe-warn-about-plain-strings';
|
|
8
|
-
import { printEffectStacktrace } from './logic/pretty-printing/print-effect-stacktrace';
|
|
9
|
-
import { prettyPrintOptionsDefault } from './types/pretty-print-options.type';
|
|
3
|
+
import { captureErrorsFrom } from './logic/errors/capture-errors-from-cause.js';
|
|
4
|
+
import { formatFailuresTitle } from './logic/pretty-printing/format-failures-title.js';
|
|
5
|
+
import { maybePrintNodeStacktrace } from './logic/pretty-printing/maybe-print-node-stacktrace.js';
|
|
6
|
+
import { maybePrintSpanAttributes } from './logic/pretty-printing/maybe-print-span-attributes.js';
|
|
7
|
+
import { maybeWarnAboutPlainStrings } from './logic/pretty-printing/maybe-warn-about-plain-strings.js';
|
|
8
|
+
import { printEffectStacktrace } from './logic/pretty-printing/print-effect-stacktrace.js';
|
|
9
|
+
import { prettyPrintOptionsDefault } from './types/pretty-print-options.type.js';
|
|
10
10
|
export const prettyPrint = (cause, options = prettyPrintOptionsDefault) => {
|
|
11
11
|
if (isInterruptedOnly(cause)) {
|
|
12
12
|
return 'All fibers interrupted without errors.';
|
package/esm/pretty-print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-print.js","names":["chalk","isInterruptedOnly","captureErrorsFrom","formatFailuresTitle","maybePrintNodeStacktrace","maybePrintSpanAttributes","maybeWarnAboutPlainStrings","printEffectStacktrace","prettyPrintOptionsDefault","prettyPrint","cause","options","failures","title","bold","yellowBright","underline","length","map","errorType","message","errorMessage","stack","span","isPlainString","failureIndex","d","spanAttributesStack","join"],"sources":["../../src/pretty-print.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAqBC,iBAAiB,QAAQ,cAAc;AAE5D,SAASC,iBAAiB,QAAQ,
|
|
1
|
+
{"version":3,"file":"pretty-print.js","names":["chalk","isInterruptedOnly","captureErrorsFrom","formatFailuresTitle","maybePrintNodeStacktrace","maybePrintSpanAttributes","maybeWarnAboutPlainStrings","printEffectStacktrace","prettyPrintOptionsDefault","prettyPrint","cause","options","failures","title","bold","yellowBright","underline","length","map","errorType","message","errorMessage","stack","span","isPlainString","failureIndex","d","spanAttributesStack","join"],"sources":["../../src/pretty-print.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAqBC,iBAAiB,QAAQ,cAAc;AAE5D,SAASC,iBAAiB,QAAQ,6CAA6C;AAC/E,SAASC,mBAAmB,QAAQ,kDAAkD;AACtF,SAASC,wBAAwB,QAAQ,wDAAwD;AACjG,SAASC,wBAAwB,QAAQ,wDAAwD;AACjG,SAASC,0BAA0B,QAAQ,2DAA2D;AACtG,SAASC,qBAAqB,QAAQ,oDAAoD;AAC1F,SAEEC,yBAAyB,QACpB,sCAAsC;AAE7C,OAAO,MAAMC,WAAW,GAAGA,CACzBC,KAAe,EACfC,OAAA,GAA8BH,yBAAyB,KAC7C;EACV,IAAIP,iBAAiB,CAACS,KAAK,CAAC,EAAE;IAC5B,OAAO,wCAAwC;EACjD;EAEA,MAAME,QAAQ,GAAGV,iBAAiB,CAAIQ,KAAK,CAAC;EAE5C,MAAMG,KAAK,GAAG,WAAWb,KAAK,CAACc,IAAI,CAACC,YAAY,CAACC,SAAS,CACxD,GAAGJ,QAAQ,CAACK,MAAM,SAASL,QAAQ,CAACK,MAAM,GAAG,CAAC,GAAG,GAAG,GAAG,EAAE,cAAc,CACxE,MAAM;EAEP,OACEJ,KAAK,GACLD,QAAQ,CACLM,GAAG,CACF,CACE;IAAEC,SAAS;IAAEC,OAAO,EAAEC,YAAY;IAAEC,KAAK;IAAEC,IAAI;IAAEC;EAAa,CAAE,EAChEC,YAAY,KACV;IACF,MAAMC,CAAC,GAAa,CAClBvB,mBAAmB,CACjBgB,SAAS,EACTE,YAAY,EACZT,QAAQ,CAACK,MAAM,EACfQ,YAAY,CACb,CACF;IAEDnB,0BAA0B,CAACoB,CAAC,EAAEF,aAAa,CAAC;IAE5C,MAAMG,mBAAmB,GAAGtB,wBAAwB,CAClDqB,CAAC,EACDH,IAAI,EACJC,aAAa,EACbb,OAAO,CACR;IAEDJ,qBAAqB,CAACmB,CAAC,EAAEH,IAAI,EAAEI,mBAAmB,EAAEhB,OAAO,CAAC;IAC5DP,wBAAwB,CAACsB,CAAC,EAAEH,IAAI,EAAED,KAAK,EAAEE,aAAa,EAAEb,OAAO,CAAC;IAEhE,OAAO,CAAC,GAAGe,CAAC,EAAE,MAAM,CAAC,CAACE,IAAI,CAAC,EAAE,CAAC;EAChC,CAAC,CACF,CACAA,IAAI,CAAC,MAAM,CAAC;AAEnB,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, pipe } from 'effect';
|
|
2
|
-
import { prettyPrint } from '
|
|
3
|
-
import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type';
|
|
2
|
+
import { prettyPrint } from '../index.js';
|
|
3
|
+
import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type.js';
|
|
4
4
|
export const runPromise = async (effect, options = prettyPrintOptionsDefault) => await Effect.runPromise(pipe(effect, Effect.sandbox, Effect.catchAll(e => {
|
|
5
5
|
if (options.enabled === false) {
|
|
6
6
|
return Effect.fail(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-promise.js","names":["Effect","pipe","prettyPrint","prettyPrintOptionsDefault","runPromise","effect","options","sandbox","catchAll","e","enabled","fail","console","error"],"sources":["../../../src/runners/run-promise.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAErC,SAASC,WAAW,QAAQ,
|
|
1
|
+
{"version":3,"file":"run-promise.js","names":["Effect","pipe","prettyPrint","prettyPrintOptionsDefault","runPromise","effect","options","sandbox","catchAll","e","enabled","fail","console","error"],"sources":["../../../src/runners/run-promise.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAErC,SAASC,WAAW,QAAQ,aAAa;AACzC,SAEEC,yBAAyB,QACpB,uCAAuC;AAE9C,OAAO,MAAMC,UAAU,GAAG,MAAAA,CACxBC,MAA2B,EAC3BC,OAAA,GAA8BH,yBAAyB,KAEvD,MAAMH,MAAM,CAACI,UAAU,CACrBH,IAAI,CACFI,MAAM,EACNL,MAAM,CAACO,OAAO,EACdP,MAAM,CAACQ,QAAQ,CAAEC,CAAC,IAAI;EACpB,IAAIH,OAAO,CAACI,OAAO,KAAK,KAAK,EAAE;IAC7B,OAAOV,MAAM,CAACW,IAAI,CAACF,CAAC,CAAC;EACvB;EAEAG,OAAO,CAACC,KAAK,CAACX,WAAW,CAACO,CAAC,EAAEH,OAAO,CAAC,CAAC;EAEtC,OAAON,MAAM,CAACW,IAAI,CAAC,sBAAsB,CAAU;AACrD,CAAC,CAAC,CACH,CACF","ignoreList":[]}
|
package/esm/runners/run-sync.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect, pipe } from 'effect';
|
|
2
|
-
import { prettyPrint } from '
|
|
3
|
-
import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type';
|
|
2
|
+
import { prettyPrint } from '../index.js';
|
|
3
|
+
import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type.js';
|
|
4
4
|
export const runSync = (effect, options = prettyPrintOptionsDefault) => Effect.runSync(pipe(effect, Effect.sandbox, Effect.catchAll(e => {
|
|
5
5
|
if (options.enabled === true) {
|
|
6
6
|
console.error(prettyPrint(e, options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-sync.js","names":["Effect","pipe","prettyPrint","prettyPrintOptionsDefault","runSync","effect","options","sandbox","catchAll","e","enabled","console","error","fail"],"sources":["../../../src/runners/run-sync.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAErC,SAASC,WAAW,QAAQ,
|
|
1
|
+
{"version":3,"file":"run-sync.js","names":["Effect","pipe","prettyPrint","prettyPrintOptionsDefault","runSync","effect","options","sandbox","catchAll","e","enabled","console","error","fail"],"sources":["../../../src/runners/run-sync.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AAErC,SAASC,WAAW,QAAQ,aAAa;AACzC,SAEEC,yBAAyB,QACpB,uCAAuC;AAE9C,OAAO,MAAMC,OAAO,GAAGA,CACrBC,MAA2B,EAC3BC,OAAA,GAA8BH,yBAAyB,KAEvDH,MAAM,CAACI,OAAO,CACZH,IAAI,CACFI,MAAM,EACNL,MAAM,CAACO,OAAO,EACdP,MAAM,CAACQ,QAAQ,CAAEC,CAAC,IAAI;EACpB,IAAIH,OAAO,CAACI,OAAO,KAAK,IAAI,EAAE;IAC5BC,OAAO,CAACC,KAAK,CAACV,WAAW,CAACO,CAAC,EAAEH,OAAO,CAAC,CAAC;IAEtC,OAAON,MAAM,CAACa,IAAI,CAAC,mBAAmB,CAAU;EAClD;EAEA,OAAOb,MAAM,CAACa,IAAI,CAACJ,CAAC,CAAC;AACvB,CAAC,CAAC,CACH,CACF","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { insertInto } from './insert-into.js';
|
|
3
|
+
// const whitePipe = chalk.whiteBright('|');
|
|
4
|
+
export const getSourceExcerpt = async (tsFileAbsolutePath, tsLine, tsColumn) => {
|
|
5
|
+
const sourceCode = await fs.readFile(tsFileAbsolutePath, {
|
|
6
|
+
encoding: 'utf-8'
|
|
7
|
+
});
|
|
8
|
+
const sourceCodeByLine = sourceCode.split('\n');
|
|
9
|
+
const start = tsLine >= 4 ? tsLine - 4 : 0;
|
|
10
|
+
const end = tsLine + 4 > sourceCodeByLine.length ? sourceCodeByLine.length : tsLine + 4;
|
|
11
|
+
return sourceCodeByLine.splice(start, 7).map((line, index) => {
|
|
12
|
+
const currentLine = index + start + 1;
|
|
13
|
+
const lineNumber = `${currentLine}`.padStart(`${end}`.length, '0');
|
|
14
|
+
const code = currentLine === tsLine ? insertInto(line, '|', tsColumn === 0 ? 0 : tsColumn - 1, 0) : line;
|
|
15
|
+
return `${lineNumber} ${code}`;
|
|
16
|
+
}).join('\n');
|
|
17
|
+
// return sourceCodeByLine
|
|
18
|
+
// .splice(start, 7)
|
|
19
|
+
// .map((line, index) => {
|
|
20
|
+
// const currentLine = index + start + 1;
|
|
21
|
+
// const lineNumber = chalk.white(
|
|
22
|
+
// `${currentLine}`.padStart(`${end}`.length, '0'),
|
|
23
|
+
// );
|
|
24
|
+
// const code =
|
|
25
|
+
// currentLine === tsLine
|
|
26
|
+
// ? chalk.redBright(
|
|
27
|
+
// insertInto(line, whitePipe, tsColumn === 0 ? 0 : tsColumn - 1, 0),
|
|
28
|
+
// )
|
|
29
|
+
// : chalk.gray(line);
|
|
30
|
+
// return `${lineNumber} ${code}`;
|
|
31
|
+
// })
|
|
32
|
+
// .join('\n');
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=get-source-excerpt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-source-excerpt.js","names":["fs","insertInto","getSourceExcerpt","tsFileAbsolutePath","tsLine","tsColumn","sourceCode","readFile","encoding","sourceCodeByLine","split","start","end","length","splice","map","line","index","currentLine","lineNumber","padStart","code","join"],"sources":["../../../src/source-maps/get-source-excerpt.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,EAAE,MAAM,UAAU;AAEzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C;AAEA,OAAO,MAAMC,gBAAgB,GAAG,MAAAA,CAC9BC,kBAA0B,EAC1BC,MAAc,EACdC,QAAgB,KACd;EACF,MAAMC,UAAU,GAAG,MAAMN,EAAE,CAACO,QAAQ,CAACJ,kBAAkB,EAAE;IACvDK,QAAQ,EAAE;GACX,CAAC;EACF,MAAMC,gBAAgB,GAAGH,UAAU,CAACI,KAAK,CAAC,IAAI,CAAC;EAE/C,MAAMC,KAAK,GAAGP,MAAM,IAAI,CAAC,GAAGA,MAAM,GAAG,CAAC,GAAG,CAAC;EAC1C,MAAMQ,GAAG,GACPR,MAAM,GAAG,CAAC,GAAGK,gBAAgB,CAACI,MAAM,GAAGJ,gBAAgB,CAACI,MAAM,GAAGT,MAAM,GAAG,CAAC;EAE7E,OAAOK,gBAAgB,CACpBK,MAAM,CAACH,KAAK,EAAE,CAAC,CAAC,CAChBI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAI;IACnB,MAAMC,WAAW,GAAGD,KAAK,GAAGN,KAAK,GAAG,CAAC;IACrC,MAAMQ,UAAU,GAAG,GAAGD,WAAW,EAAE,CAACE,QAAQ,CAAC,GAAGR,GAAG,EAAE,CAACC,MAAM,EAAE,GAAG,CAAC;IAClE,MAAMQ,IAAI,GACRH,WAAW,KAAKd,MAAM,GAClBH,UAAU,CAACe,IAAI,EAAE,GAAG,EAAEX,QAAQ,KAAK,CAAC,GAAG,CAAC,GAAGA,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,GAC3DW,IAAI;IAEV,OAAO,GAAGG,UAAU,IAAIE,IAAI,EAAE;EAChC,CAAC,CAAC,CACDC,IAAI,CAAC,IAAI,CAAC;EAEb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import { SourceMapConsumer } from 'source-map';
|
|
5
|
+
import { getSourceExcerpt } from './get-source-excerpt.js';
|
|
6
|
+
const sourceFileRegex = /^(file:\/\/)?(.*.(j|t)s)(\?.*)?:(\d*):(\d*)$/;
|
|
7
|
+
export const getTsCodeFromSourcemap = async sourceFile => {
|
|
8
|
+
const regex = sourceFileRegex.exec(sourceFile);
|
|
9
|
+
if (regex === null || regex.length !== 7) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const filePath = regex[2];
|
|
13
|
+
const line = +regex[5];
|
|
14
|
+
const column = +regex[6];
|
|
15
|
+
if (filePath.endsWith('.ts')) {
|
|
16
|
+
const codeExcerpt = await getSourceExcerpt(filePath, line, column);
|
|
17
|
+
return {
|
|
18
|
+
file: `${filePath}:${line}:${column}`,
|
|
19
|
+
codeExcerpt
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const fileExists = await fs.exists(`${filePath}.map`);
|
|
23
|
+
if (!fileExists) {
|
|
24
|
+
console.warn(`${chalk.blueBright.underline('effect-errors')}: ${chalk.yellow(`${filePath}.map does not exist: unable to retrieve spans sourcemaps.`)} `);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const data = await fs.readFile(`${filePath}.map`, {
|
|
28
|
+
encoding: 'utf-8'
|
|
29
|
+
});
|
|
30
|
+
return await SourceMapConsumer.with(data, null, async consumer => {
|
|
31
|
+
const tsCode = consumer.originalPositionFor({
|
|
32
|
+
line,
|
|
33
|
+
column
|
|
34
|
+
});
|
|
35
|
+
if (tsCode.source === null || tsCode.line === null || tsCode.column === null) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const tsFileAbsolutePath = path.resolve(filePath.substring(0, filePath.lastIndexOf('/')), tsCode.source);
|
|
39
|
+
const codeExcerpt = await getSourceExcerpt(tsFileAbsolutePath, tsCode.line, tsCode.column);
|
|
40
|
+
return {
|
|
41
|
+
file: `${tsFileAbsolutePath}:${tsCode.line}:${tsCode.column}`,
|
|
42
|
+
codeExcerpt
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=get-ts-code-from-sourcemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-ts-code-from-sourcemap.js","names":["path","chalk","fs","SourceMapConsumer","getSourceExcerpt","sourceFileRegex","getTsCodeFromSourcemap","sourceFile","regex","exec","length","filePath","line","column","endsWith","codeExcerpt","file","fileExists","exists","console","warn","blueBright","underline","yellow","data","readFile","encoding","with","consumer","tsCode","originalPositionFor","source","tsFileAbsolutePath","resolve","substring","lastIndexOf"],"sources":["../../../src/source-maps/get-ts-code-from-sourcemap.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,EAAE,MAAM,UAAU;AACzB,SAASC,iBAAiB,QAAQ,YAAY;AAE9C,SAASC,gBAAgB,QAAQ,yBAAyB;AAE1D,MAAMC,eAAe,GAAG,8CAA8C;AAOtE,OAAO,MAAMC,sBAAsB,GAAG,MACpCC,UAAkB,IACyB;EAC3C,MAAMC,KAAK,GAAGH,eAAe,CAACI,IAAI,CAACF,UAAU,CAAC;EAC9C,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,CAACE,MAAM,KAAK,CAAC,EAAE;IACxC;EACF;EAEA,MAAMC,QAAQ,GAAGH,KAAK,CAAC,CAAC,CAAC;EACzB,MAAMI,IAAI,GAAG,CAACJ,KAAK,CAAC,CAAC,CAAC;EACtB,MAAMK,MAAM,GAAG,CAACL,KAAK,CAAC,CAAC,CAAC;EAExB,IAAIG,QAAQ,CAACG,QAAQ,CAAC,KAAK,CAAC,EAAE;IAC5B,MAAMC,WAAW,GAAG,MAAMX,gBAAgB,CAACO,QAAQ,EAAEC,IAAI,EAAEC,MAAM,CAAC;IAElE,OAAO;MACLG,IAAI,EAAE,GAAGL,QAAQ,IAAIC,IAAI,IAAIC,MAAM,EAAE;MACrCE;KACD;EACH;EAEA,MAAME,UAAU,GAAG,MAAMf,EAAE,CAACgB,MAAM,CAAC,GAAGP,QAAQ,MAAM,CAAC;EACrD,IAAI,CAACM,UAAU,EAAE;IACfE,OAAO,CAACC,IAAI,CACV,GAAGnB,KAAK,CAACoB,UAAU,CAACC,SAAS,CAAC,eAAe,CAAC,KAAKrB,KAAK,CAACsB,MAAM,CAAC,GAAGZ,QAAQ,2DAA2D,CAAC,IAAI,CAC5I;IACD;EACF;EAEA,MAAMa,IAAI,GAAG,MAAMtB,EAAE,CAACuB,QAAQ,CAAC,GAAGd,QAAQ,MAAM,EAAE;IAChDe,QAAQ,EAAE;GACX,CAAC;EAEF,OAAO,MAAMvB,iBAAiB,CAACwB,IAAI,CAACH,IAAI,EAAE,IAAI,EAAE,MAAOI,QAAQ,IAAI;IACjE,MAAMC,MAAM,GAAGD,QAAQ,CAACE,mBAAmB,CAAC;MAAElB,IAAI;MAAEC;IAAM,CAAE,CAAC;IAC7D,IACEgB,MAAM,CAACE,MAAM,KAAK,IAAI,IACtBF,MAAM,CAACjB,IAAI,KAAK,IAAI,IACpBiB,MAAM,CAAChB,MAAM,KAAK,IAAI,EACtB;MACA;IACF;IAEA,MAAMmB,kBAAkB,GAAGhC,IAAI,CAACiC,OAAO,CACrCtB,QAAQ,CAACuB,SAAS,CAAC,CAAC,EAAEvB,QAAQ,CAACwB,WAAW,CAAC,GAAG,CAAC,CAAC,EAChDN,MAAM,CAACE,MAAM,CACd;IAED,MAAMhB,WAAW,GAAG,MAAMX,gBAAgB,CACxC4B,kBAAkB,EAClBH,MAAM,CAACjB,IAAI,EACXiB,MAAM,CAAChB,MAAM,CACd;IAED,OAAO;MACLG,IAAI,EAAE,GAAGgB,kBAAkB,IAAIH,MAAM,CAACjB,IAAI,IAAIiB,MAAM,CAAChB,MAAM,EAAE;MAC7DE;KACD;EACH,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-into.js","names":["insertInto","input","data","start","delCount","slice","Math","abs"],"sources":["../../../src/source-maps/insert-into.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,UAAU,GAAGA,CACxBC,KAAa,EACbC,IAAY,EACZC,KAAa,EACbC,QAAgB,KACbH,KAAK,CAACI,KAAK,CAAC,CAAC,EAAEF,KAAK,CAAC,GAAGD,IAAI,GAAGD,KAAK,CAACI,KAAK,CAACF,KAAK,GAAGG,IAAI,CAACC,GAAG,CAACH,QAAQ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fileRegex, stackAtRegex } from '../logic/stack/stack-regex.js';
|
|
2
|
+
import { getTsCodeFromSourcemap } from './get-ts-code-from-sourcemap.js';
|
|
3
|
+
export const maybeMapSourcemaps = async stacktrace => await Promise.all(stacktrace.map(async stackLine => {
|
|
4
|
+
const matches = stackLine.matchAll(/^at .*\((.*)\)$/g);
|
|
5
|
+
const path = [...matches].map(el => el[1])[0];
|
|
6
|
+
const r = await getTsCodeFromSourcemap(path);
|
|
7
|
+
if (r === undefined) {
|
|
8
|
+
return {
|
|
9
|
+
file: stackLine.replaceAll(stackAtRegex, 'at '),
|
|
10
|
+
codeExcerpt: ''
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
file: stackLine.replaceAll(stackAtRegex, 'at ').replaceAll(fileRegex, `(${r.file})`),
|
|
15
|
+
codeExcerpt: r.codeExcerpt
|
|
16
|
+
};
|
|
17
|
+
}));
|
|
18
|
+
//# sourceMappingURL=maybe-map-sourcemaps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe-map-sourcemaps.js","names":["fileRegex","stackAtRegex","getTsCodeFromSourcemap","maybeMapSourcemaps","stacktrace","Promise","all","map","stackLine","matches","matchAll","path","el","r","undefined","file","replaceAll","codeExcerpt"],"sources":["../../../src/source-maps/maybe-map-sourcemaps.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,SAAS,EAAEC,YAAY,QAAQ,+BAA+B;AAEvE,SACEC,sBAAsB,QAEjB,iCAAiC;AAExC,OAAO,MAAMC,kBAAkB,GAAG,MAChCC,UAAoB,IAEpB,MAAMC,OAAO,CAACC,GAAG,CACfF,UAAU,CAACG,GAAG,CAAC,MAAOC,SAAS,IAAI;EACjC,MAAMC,OAAO,GAAGD,SAAS,CAACE,QAAQ,CAAC,kBAAkB,CAAC;EACtD,MAAMC,IAAI,GAAG,CAAC,GAAGF,OAAO,CAAC,CAACF,GAAG,CAAEK,EAAE,IAAKA,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;EAE/C,MAAMC,CAAC,GAAG,MAAMX,sBAAsB,CAACS,IAAI,CAAC;EAC5C,IAAIE,CAAC,KAAKC,SAAS,EAAE;IACnB,OAAO;MACLC,IAAI,EAAEP,SAAS,CAACQ,UAAU,CAACf,YAAY,EAAE,KAAK,CAAC;MAC/CgB,WAAW,EAAE;KACd;EACH;EAEA,OAAO;IACLF,IAAI,EAAEP,SAAS,CACZQ,UAAU,CAACf,YAAY,EAAE,KAAK,CAAC,CAC/Be,UAAU,CAAChB,SAAS,EAAE,IAAIa,CAAC,CAACE,IAAI,GAAG,CAAC;IACvCE,WAAW,EAAEJ,CAAC,CAACI;GAChB;AACH,CAAC,CAAC,CACH","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"name": "effect-errors",
|
|
17
|
-
"version": "1.4.
|
|
17
|
+
"version": "1.4.6",
|
|
18
18
|
"author": "jpb06 <jp.bois.06@outlook.fr>",
|
|
19
19
|
"description": "A POC for errors reporting in Effect",
|
|
20
20
|
"keywords": [
|
|
@@ -45,15 +45,17 @@
|
|
|
45
45
|
"run-examples": "bun run ./src/examples/util/run-all"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@effect/schema": "^0.67.
|
|
48
|
+
"@effect/schema": "^0.67.13",
|
|
49
49
|
"chalk": "<5",
|
|
50
|
-
"
|
|
50
|
+
"convert-source-map": "^2.0.0",
|
|
51
|
+
"effect": "^3.2.5",
|
|
52
|
+
"source-map": "^0.7.4"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
|
-
"@babel/cli": "^7.24.
|
|
54
|
-
"@babel/core": "^7.24.
|
|
55
|
-
"@babel/plugin-transform-export-namespace-from": "^7.24.
|
|
56
|
-
"@babel/plugin-transform-modules-commonjs": "^7.24.
|
|
55
|
+
"@babel/cli": "^7.24.6",
|
|
56
|
+
"@babel/core": "^7.24.6",
|
|
57
|
+
"@babel/plugin-transform-export-namespace-from": "^7.24.6",
|
|
58
|
+
"@babel/plugin-transform-modules-commonjs": "^7.24.6",
|
|
57
59
|
"@eslint/eslintrc": "^3.1.0",
|
|
58
60
|
"@eslint/js": "^9.3.0",
|
|
59
61
|
"@stylistic/eslint-plugin": "^2.1.0",
|
|
@@ -82,7 +84,7 @@
|
|
|
82
84
|
"prettier": "^3.2.5",
|
|
83
85
|
"readme-package-icons": "^1.1.14",
|
|
84
86
|
"ts-node": "^10.9.2",
|
|
85
|
-
"tsx": "^4.
|
|
87
|
+
"tsx": "^4.11.0",
|
|
86
88
|
"typescript": "^5.4.5",
|
|
87
89
|
"typescript-eslint": "^7.10.0",
|
|
88
90
|
"vitest": "^1.6.0",
|