effect-errors 1.3.12 → 1.4.2

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.
Files changed (169) hide show
  1. package/README.md +10 -6
  2. package/cjs/capture-errors.js +74 -0
  3. package/cjs/capture-errors.js.map +1 -0
  4. package/cjs/index.js +61 -0
  5. package/cjs/index.js.map +1 -0
  6. package/cjs/logic/errors/capture-errors-from-cause.js +18 -0
  7. package/cjs/logic/errors/capture-errors-from-cause.js.map +1 -0
  8. package/cjs/logic/errors/extract-error-details.js +63 -0
  9. package/cjs/logic/errors/extract-error-details.js.map +1 -0
  10. package/cjs/logic/errors/parse-error.js +24 -0
  11. package/cjs/logic/errors/parse-error.js.map +1 -0
  12. package/cjs/logic/pretty-printing/format-failures-title.js +15 -0
  13. package/cjs/logic/pretty-printing/format-failures-title.js.map +1 -0
  14. package/cjs/logic/pretty-printing/format-span-attributes.js +55 -0
  15. package/cjs/logic/pretty-printing/format-span-attributes.js.map +1 -0
  16. package/cjs/logic/pretty-printing/maybe-print-node-stacktrace.js +24 -0
  17. package/cjs/logic/pretty-printing/maybe-print-node-stacktrace.js.map +1 -0
  18. package/cjs/logic/pretty-printing/maybe-print-span-attributes.js +31 -0
  19. package/cjs/logic/pretty-printing/maybe-print-span-attributes.js.map +1 -0
  20. package/cjs/logic/pretty-printing/maybe-warn-about-plain-strings.js +20 -0
  21. package/cjs/logic/pretty-printing/maybe-warn-about-plain-strings.js.map +1 -0
  22. package/cjs/logic/pretty-printing/print-effect-stacktrace.js +24 -0
  23. package/cjs/logic/pretty-printing/print-effect-stacktrace.js.map +1 -0
  24. package/cjs/logic/spans/get-span-attributes.js +33 -0
  25. package/cjs/logic/spans/get-span-attributes.js.map +1 -0
  26. package/cjs/logic/spans/get-span-duration.js +21 -0
  27. package/cjs/logic/spans/get-span-duration.js.map +1 -0
  28. package/cjs/logic/spans/spans-stack-trailing-char.js +15 -0
  29. package/cjs/logic/spans/spans-stack-trailing-char.js.map +1 -0
  30. package/cjs/logic/spans/split-spans-attributes-by-type.js +23 -0
  31. package/cjs/logic/spans/split-spans-attributes-by-type.js.map +1 -0
  32. package/cjs/logic/stack/filter-stack.js +21 -0
  33. package/cjs/logic/stack/filter-stack.js.map +1 -0
  34. package/cjs/logic/strip-cwd-path.js +10 -0
  35. package/cjs/logic/strip-cwd-path.js.map +1 -0
  36. package/cjs/pretty-print.js +43 -0
  37. package/cjs/pretty-print.js.map +1 -0
  38. package/cjs/runners/run-promise.js +18 -0
  39. package/cjs/runners/run-promise.js.map +1 -0
  40. package/cjs/runners/run-sync.js +18 -0
  41. package/cjs/runners/run-sync.js.map +1 -0
  42. package/cjs/types/pretty-error.type.js +22 -0
  43. package/cjs/types/pretty-error.type.js.map +1 -0
  44. package/cjs/types/pretty-print-options.type.js +12 -0
  45. package/cjs/types/pretty-print-options.type.js.map +1 -0
  46. package/{capture-errors.d.ts → dts/capture-errors.d.ts} +3 -1
  47. package/dts/capture-errors.d.ts.map +1 -0
  48. package/dts/index.d.ts +6 -0
  49. package/dts/index.d.ts.map +1 -0
  50. package/{logic → dts/logic}/errors/capture-errors-from-cause.d.ts +1 -0
  51. package/dts/logic/errors/capture-errors-from-cause.d.ts.map +1 -0
  52. package/{logic → dts/logic}/errors/extract-error-details.d.ts +1 -0
  53. package/dts/logic/errors/extract-error-details.d.ts.map +1 -0
  54. package/{logic → dts/logic}/errors/parse-error.d.ts +1 -0
  55. package/dts/logic/errors/parse-error.d.ts.map +1 -0
  56. package/dts/logic/pretty-printing/format-failures-title.d.ts +2 -0
  57. package/dts/logic/pretty-printing/format-failures-title.d.ts.map +1 -0
  58. package/dts/logic/pretty-printing/format-span-attributes.d.ts +7 -0
  59. package/dts/logic/pretty-printing/format-span-attributes.d.ts.map +1 -0
  60. package/dts/logic/pretty-printing/maybe-print-node-stacktrace.d.ts +4 -0
  61. package/dts/logic/pretty-printing/maybe-print-node-stacktrace.d.ts.map +1 -0
  62. package/dts/logic/pretty-printing/maybe-print-span-attributes.d.ts +4 -0
  63. package/dts/logic/pretty-printing/maybe-print-span-attributes.d.ts.map +1 -0
  64. package/dts/logic/pretty-printing/maybe-warn-about-plain-strings.d.ts +2 -0
  65. package/dts/logic/pretty-printing/maybe-warn-about-plain-strings.d.ts.map +1 -0
  66. package/dts/logic/pretty-printing/print-effect-stacktrace.d.ts +4 -0
  67. package/dts/logic/pretty-printing/print-effect-stacktrace.d.ts.map +1 -0
  68. package/dts/logic/spans/get-span-attributes.d.ts +5 -0
  69. package/dts/logic/spans/get-span-attributes.d.ts.map +1 -0
  70. package/{logic → dts/logic}/spans/get-span-duration.d.ts +1 -0
  71. package/dts/logic/spans/get-span-duration.d.ts.map +1 -0
  72. package/{logic → dts/logic}/spans/spans-stack-trailing-char.d.ts +1 -0
  73. package/dts/logic/spans/spans-stack-trailing-char.d.ts.map +1 -0
  74. package/dts/logic/spans/split-spans-attributes-by-type.d.ts +7 -0
  75. package/dts/logic/spans/split-spans-attributes-by-type.d.ts.map +1 -0
  76. package/{logic → dts/logic}/stack/filter-stack.d.ts +1 -0
  77. package/dts/logic/stack/filter-stack.d.ts.map +1 -0
  78. package/{logic → dts/logic}/strip-cwd-path.d.ts +1 -0
  79. package/dts/logic/strip-cwd-path.d.ts.map +1 -0
  80. package/dts/pretty-print.d.ts +4 -0
  81. package/dts/pretty-print.d.ts.map +1 -0
  82. package/{runners → dts/runners}/run-promise.d.ts +1 -0
  83. package/dts/runners/run-promise.d.ts.map +1 -0
  84. package/{runners → dts/runners}/run-sync.d.ts +1 -0
  85. package/dts/runners/run-sync.d.ts.map +1 -0
  86. package/{types → dts/types}/pretty-error.type.d.ts +1 -0
  87. package/dts/types/pretty-error.type.d.ts.map +1 -0
  88. package/{types → dts/types}/pretty-print-options.type.d.ts +1 -0
  89. package/dts/types/pretty-print-options.type.d.ts.map +1 -0
  90. package/esm/capture-errors.js +67 -0
  91. package/esm/capture-errors.js.map +1 -0
  92. package/{index.d.ts → esm/index.js} +1 -0
  93. package/esm/index.js.map +1 -0
  94. package/esm/logic/errors/capture-errors-from-cause.js +11 -0
  95. package/esm/logic/errors/capture-errors-from-cause.js.map +1 -0
  96. package/esm/logic/errors/extract-error-details.js +56 -0
  97. package/esm/logic/errors/extract-error-details.js.map +1 -0
  98. package/esm/logic/errors/parse-error.js +17 -0
  99. package/esm/logic/errors/parse-error.js.map +1 -0
  100. package/esm/logic/pretty-printing/format-failures-title.js +3 -0
  101. package/esm/logic/pretty-printing/format-failures-title.js.map +1 -0
  102. package/esm/logic/pretty-printing/format-span-attributes.js +43 -0
  103. package/esm/logic/pretty-printing/format-span-attributes.js.map +1 -0
  104. package/esm/logic/pretty-printing/maybe-print-node-stacktrace.js +12 -0
  105. package/esm/logic/pretty-printing/maybe-print-node-stacktrace.js.map +1 -0
  106. package/esm/logic/pretty-printing/maybe-print-span-attributes.js +19 -0
  107. package/esm/logic/pretty-printing/maybe-print-span-attributes.js.map +1 -0
  108. package/esm/logic/pretty-printing/maybe-warn-about-plain-strings.js +8 -0
  109. package/esm/logic/pretty-printing/maybe-warn-about-plain-strings.js.map +1 -0
  110. package/esm/logic/pretty-printing/print-effect-stacktrace.js +12 -0
  111. package/esm/logic/pretty-printing/print-effect-stacktrace.js.map +1 -0
  112. package/esm/logic/spans/get-span-attributes.js +21 -0
  113. package/esm/logic/spans/get-span-attributes.js.map +1 -0
  114. package/esm/logic/spans/get-span-duration.js +9 -0
  115. package/esm/logic/spans/get-span-duration.js.map +1 -0
  116. package/esm/logic/spans/spans-stack-trailing-char.js +3 -0
  117. package/esm/logic/spans/spans-stack-trailing-char.js.map +1 -0
  118. package/esm/logic/spans/split-spans-attributes-by-type.js +16 -0
  119. package/esm/logic/spans/split-spans-attributes-by-type.js.map +1 -0
  120. package/esm/logic/stack/filter-stack.js +14 -0
  121. package/esm/logic/stack/filter-stack.js.map +1 -0
  122. package/esm/logic/strip-cwd-path.js +3 -0
  123. package/esm/logic/strip-cwd-path.js.map +1 -0
  124. package/esm/pretty-print.js +31 -0
  125. package/esm/pretty-print.js.map +1 -0
  126. package/esm/runners/run-promise.js +11 -0
  127. package/esm/runners/run-promise.js.map +1 -0
  128. package/esm/runners/run-sync.js +11 -0
  129. package/esm/runners/run-sync.js.map +1 -0
  130. package/esm/types/pretty-error.type.js +15 -0
  131. package/esm/types/pretty-error.type.js.map +1 -0
  132. package/esm/types/pretty-print-options.type.js +6 -0
  133. package/esm/types/pretty-print-options.type.js.map +1 -0
  134. package/package.json +29 -14
  135. package/capture-errors.js +0 -51
  136. package/capture-errors.test.d.ts +0 -1
  137. package/capture-errors.test.js +0 -162
  138. package/examples/errors/fetch-error.d.ts +0 -9
  139. package/examples/errors/fetch-error.js +0 -27
  140. package/examples/errors/file-error.d.ts +0 -9
  141. package/examples/errors/file-error.js +0 -27
  142. package/examples/errors/user-not-found.error.d.ts +0 -9
  143. package/examples/errors/user-not-found.error.js +0 -27
  144. package/examples/from-promise.d.ts +0 -5
  145. package/examples/from-promise.js +0 -113
  146. package/examples/parallel-errors.d.ts +0 -4
  147. package/examples/parallel-errors.js +0 -69
  148. package/examples/util/filename.effect.d.ts +0 -2
  149. package/examples/util/filename.effect.js +0 -11
  150. package/index.js +0 -21
  151. package/logic/errors/capture-errors-from-cause.js +0 -41
  152. package/logic/errors/extract-error-details.js +0 -74
  153. package/logic/errors/parse-error.js +0 -19
  154. package/logic/spans/get-span-attributes.d.ts +0 -1
  155. package/logic/spans/get-span-attributes.js +0 -36
  156. package/logic/spans/get-span-duration.js +0 -15
  157. package/logic/spans/spans-stack-trailing-char.js +0 -11
  158. package/logic/stack/filter-stack.js +0 -39
  159. package/logic/strip-cwd-path.js +0 -8
  160. package/pretty-print.d.ts +0 -3
  161. package/pretty-print.js +0 -75
  162. package/runners/run-promise.js +0 -89
  163. package/runners/run-sync.js +0 -17
  164. package/tests/mocks/console.mock.d.ts +0 -9
  165. package/tests/mocks/console.mock.js +0 -66
  166. package/tests/runners/effect-cause.d.ts +0 -2
  167. package/tests/runners/effect-cause.js +0 -49
  168. package/types/pretty-error.type.js +0 -14
  169. package/types/pretty-print-options.type.js +0 -8
@@ -0,0 +1,17 @@
1
+ import { hasProperty } from 'effect/Predicate';
2
+ import { PrettyError } from '../../types/pretty-error.type';
3
+ import { extractErrorDetails } from './extract-error-details';
4
+ const spanSymbol = /*#__PURE__*/Symbol.for('effect/SpanAnnotation');
5
+ export const parseError = error => {
6
+ const span = hasProperty(error, spanSymbol) ? error[spanSymbol] : undefined;
7
+ const {
8
+ message,
9
+ type,
10
+ isPlainString
11
+ } = extractErrorDetails(error);
12
+ if (error instanceof Error) {
13
+ return new PrettyError(message, error.stack?.split('\n').filter(el => /at (.*)/.exec(el)).join('\r\n'), span, false, type);
14
+ }
15
+ return new PrettyError(message, undefined, span, isPlainString, type);
16
+ };
17
+ //# sourceMappingURL=parse-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-error.js","names":["hasProperty","PrettyError","extractErrorDetails","spanSymbol","Symbol","for","parseError","error","span","undefined","message","type","isPlainString","Error","stack","split","filter","el","exec","join"],"sources":["../../../../src/logic/errors/parse-error.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,kBAAkB;AAG9C,SAASC,WAAW,QAAQ,+BAA+B;AAE3D,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,MAAMC,UAAU,gBAAGC,MAAM,CAACC,GAAG,CAAC,uBAAuB,CAAC;AAEtD,OAAO,MAAMC,UAAU,GAAIC,KAAc,IAAiB;EACxD,MAAMC,IAAI,GAAGR,WAAW,CAACO,KAAK,EAAEJ,UAAU,CAAC,GACtCI,KAAK,CAACJ,UAAU,CAAU,GAC3BM,SAAS;EACb,MAAM;IAAEC,OAAO;IAAEC,IAAI;IAAEC;EAAa,CAAE,GAAGV,mBAAmB,CAACK,KAAK,CAAC;EAEnE,IAAIA,KAAK,YAAYM,KAAK,EAAE;IAC1B,OAAO,IAAIZ,WAAW,CACpBS,OAAO,EACPH,KAAK,CAACO,KAAK,EACPC,KAAK,CAAC,IAAI,CAAC,CACZC,MAAM,CAAEC,EAAE,IAAK,SAAS,CAACC,IAAI,CAACD,EAAE,CAAC,CAAC,CAClCE,IAAI,CAAC,MAAM,CAAC,EACfX,IAAI,EACJ,KAAK,EACLG,IAAI,CACL;EACH;EAEA,OAAO,IAAIV,WAAW,CAACS,OAAO,EAAED,SAAS,EAAED,IAAI,EAAEI,aAAa,EAAED,IAAI,CAAC;AACvE,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import chalk from 'chalk';
2
+ export const formatFailuresTitle = (errorType, message, failuresLength, failureIndex) => '💥 ' + (failuresLength > 1 ? chalk.bgRed.whiteBright(` #${failureIndex + 1} -`) : '') + chalk.bgRed.whiteBright(` ${errorType ?? 'Unknown error'} `) + chalk.bold.whiteBright(` • ${message}`) + '\r\n';
3
+ //# sourceMappingURL=format-failures-title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-failures-title.js","names":["chalk","formatFailuresTitle","errorType","message","failuresLength","failureIndex","bgRed","whiteBright","bold"],"sources":["../../../../src/logic/pretty-printing/format-failures-title.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,SAAkB,EAClBC,OAAgB,EAChBC,cAAsB,EACtBC,YAAoB,KAEpB,KAAK,IACJD,cAAc,GAAG,CAAC,GACfJ,KAAK,CAACM,KAAK,CAACC,WAAW,CAAC,KAAKF,YAAY,GAAG,CAAC,IAAI,CAAC,GAClD,EAAE,CAAC,GACPL,KAAK,CAACM,KAAK,CAACC,WAAW,CACrB,IAAKL,SAAgC,IAAI,eAAe,GAAG,CAC5D,GACDF,KAAK,CAACQ,IAAI,CAACD,WAAW,CAAC,MAAMJ,OAAiB,EAAE,CAAC,GACjD,MAAM","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ import chalk from 'chalk';
2
+ import { Option } from 'effect';
3
+ import { getSpanAttributes } from '../spans/get-span-attributes';
4
+ import { getSpanDuration } from '../spans/get-span-duration';
5
+ import { spanStackTrailingChar } from '../spans/spans-stack-trailing-char';
6
+ import { stripCwdPath } from '../strip-cwd-path';
7
+ export const formatSpanAttributes = (span, {
8
+ stripCwd,
9
+ reverseSpans
10
+ }) => {
11
+ let current = span;
12
+ const spans = [];
13
+ while (current !== undefined && current._tag === 'Span') {
14
+ spans.push(current);
15
+ current = Option.getOrUndefined(current.parent);
16
+ }
17
+ const orderedSpans = reverseSpans === true ? spans.toReversed() : spans;
18
+ return orderedSpans.map(({
19
+ name,
20
+ attributes,
21
+ status
22
+ }, index) => {
23
+ const isFirstEntry = index === 0;
24
+ const isLastEntry = index === spans.length - 1;
25
+ const filePath = ` at ${stripCwd !== undefined ? stripCwdPath(name) : name}`;
26
+ const {
27
+ formattedAttributes,
28
+ stack
29
+ } = getSpanAttributes(attributes, isLastEntry);
30
+ const message = chalk.whiteBright((isFirstEntry ? `\r\n${chalk.gray('◯')}` : '') + '\r\n' + spanStackTrailingChar(isLastEntry) + chalk.gray('─') + filePath + getSpanDuration(status, isLastEntry) + formattedAttributes);
31
+ return {
32
+ message,
33
+ stack
34
+ };
35
+ }).reduce((prev, curr) => ({
36
+ message: prev.message + curr.message,
37
+ stack: [...prev.stack, ...curr.stack]
38
+ }), {
39
+ message: '',
40
+ stack: []
41
+ });
42
+ };
43
+ //# sourceMappingURL=format-span-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-span-attributes.js","names":["chalk","Option","getSpanAttributes","getSpanDuration","spanStackTrailingChar","stripCwdPath","formatSpanAttributes","span","stripCwd","reverseSpans","current","spans","undefined","_tag","push","getOrUndefined","parent","orderedSpans","toReversed","map","name","attributes","status","index","isFirstEntry","isLastEntry","length","filePath","formattedAttributes","stack","message","whiteBright","gray","reduce","prev","curr"],"sources":["../../../../src/logic/pretty-printing/format-span-attributes.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,QAAQ;AAI/B,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SAASC,qBAAqB,QAAQ,oCAAoC;AAC1E,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAsB,EACtB;EAAEC,QAAQ;EAAEC;AAAY,CAAsB,KAC5C;EACF,IAAIC,OAAO,GAA+BH,IAAI;EAE9C,MAAMI,KAAK,GAAG,EAAE;EAChB,OAAOD,OAAO,KAAKE,SAAS,IAAIF,OAAO,CAACG,IAAI,KAAK,MAAM,EAAE;IACvDF,KAAK,CAACG,IAAI,CAACJ,OAAO,CAAC;IACnBA,OAAO,GAAGT,MAAM,CAACc,cAAc,CAACL,OAAO,CAACM,MAAM,CAAC;EACjD;EAEA,MAAMC,YAAY,GAAGR,YAAY,KAAK,IAAI,GAAGE,KAAK,CAACO,UAAU,EAAE,GAAGP,KAAK;EAEvE,OAAOM,YAAY,CAChBE,GAAG,CAAC,CAAC;IAAEC,IAAI;IAAEC,UAAU;IAAEC;EAAM,CAAE,EAAEC,KAAK,KAAI;IAC3C,MAAMC,YAAY,GAAGD,KAAK,KAAK,CAAC;IAChC,MAAME,WAAW,GAAGF,KAAK,KAAKZ,KAAK,CAACe,MAAM,GAAG,CAAC;IAE9C,MAAMC,QAAQ,GAAG,OAAOnB,QAAQ,KAAKI,SAAS,GAAGP,YAAY,CAACe,IAAI,CAAC,GAAGA,IAAI,EAAE;IAE5E,MAAM;MAAEQ,mBAAmB;MAAEC;IAAK,CAAE,GAAG3B,iBAAiB,CACtDmB,UAAU,EACVI,WAAW,CACZ;IAED,MAAMK,OAAO,GAAG9B,KAAK,CAAC+B,WAAW,CAC/B,CAACP,YAAY,GAAG,OAAOxB,KAAK,CAACgC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAC3C,MAAM,GACN5B,qBAAqB,CAACqB,WAAW,CAAC,GAClCzB,KAAK,CAACgC,IAAI,CAAC,GAAG,CAAC,GACfL,QAAQ,GACRxB,eAAe,CAACmB,MAAM,EAAEG,WAAW,CAAC,GACpCG,mBAAmB,CACtB;IAED,OAAO;MACLE,OAAO;MACPD;KACD;EACH,CAAC,CAAC,CACDI,MAAM,CACL,CAACC,IAAI,EAAEC,IAAI,MAAM;IACfL,OAAO,EAAEI,IAAI,CAACJ,OAAO,GAAGK,IAAI,CAACL,OAAO;IACpCD,KAAK,EAAE,CAAC,GAAGK,IAAI,CAACL,KAAK,EAAE,GAAGM,IAAI,CAACN,KAAK;GACrC,CAAC,EACF;IACEC,OAAO,EAAE,EAAE;IACXD,KAAK,EAAE;GACR,CACF;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import chalk from 'chalk';
2
+ import { filterStack } from '../stack/filter-stack';
3
+ export const maybePrintNodeStacktrace = (d, span, stack, isPlainString, {
4
+ stripCwd
5
+ }) => {
6
+ if (stack !== undefined) {
7
+ d.push(`\r\n${span !== undefined ? '\r\n' : ''}🚨 Node Stacktrace\r\n${chalk.red(filterStack(stack, stripCwd === true))}`);
8
+ } else if (!isPlainString) {
9
+ d.push(`\r\n\r\n${chalk.gray('ℹ️ Consider using a yieldable error such as Data.TaggedError and Schema.TaggedError to get a stacktrace.')}`);
10
+ }
11
+ };
12
+ //# sourceMappingURL=maybe-print-node-stacktrace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe-print-node-stacktrace.js","names":["chalk","filterStack","maybePrintNodeStacktrace","d","span","stack","isPlainString","stripCwd","undefined","push","red","gray"],"sources":["../../../../src/logic/pretty-printing/maybe-print-node-stacktrace.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,OAAO,MAAMC,wBAAwB,GAAGA,CACtCC,CAAW,EACXC,IAAsB,EACtBC,KAAyB,EACzBC,aAAsB,EACtB;EAAEC;AAAQ,CAAsB,KAC9B;EACF,IAAIF,KAAK,KAAKG,SAAS,EAAE;IACvBL,CAAC,CAACM,IAAI,CACJ,OAAOL,IAAI,KAAKI,SAAS,GAAG,MAAM,GAAG,EAAE,yBAAyBR,KAAK,CAACU,GAAG,CAACT,WAAW,CAACI,KAAK,EAAEE,QAAQ,KAAK,IAAI,CAAC,CAAC,EAAE,CACnH;EACH,CAAC,MAAM,IAAI,CAACD,aAAa,EAAE;IACzBH,CAAC,CAACM,IAAI,CACJ,WAAWT,KAAK,CAACW,IAAI,CAAC,2GAA2G,CAAC,EAAE,CACrI;EACH;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import chalk from 'chalk';
2
+ import { formatSpanAttributes } from './format-span-attributes';
3
+ export const maybePrintSpanAttributes = (d, span, isPlainString, {
4
+ stripCwd,
5
+ reverseSpans
6
+ }) => {
7
+ if (span !== undefined) {
8
+ const spanData = formatSpanAttributes(span, {
9
+ stripCwd,
10
+ reverseSpans
11
+ });
12
+ d.push(spanData.message);
13
+ return spanData.stack;
14
+ }
15
+ if (!isPlainString) {
16
+ d.push(`\r\n${chalk.gray('ℹ️ Consider using spans to improve errors reporting.\r\n')}`);
17
+ }
18
+ };
19
+ //# sourceMappingURL=maybe-print-span-attributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe-print-span-attributes.js","names":["chalk","formatSpanAttributes","maybePrintSpanAttributes","d","span","isPlainString","stripCwd","reverseSpans","undefined","spanData","push","message","stack","gray"],"sources":["../../../../src/logic/pretty-printing/maybe-print-span-attributes.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAKzB,SAASC,oBAAoB,QAAQ,0BAA0B;AAE/D,OAAO,MAAMC,wBAAwB,GAAGA,CACtCC,CAAW,EACXC,IAAsB,EACtBC,aAAsB,EACtB;EAAEC,QAAQ;EAAEC;AAAY,CAAsB,KAC5C;EACF,IAAIH,IAAI,KAAKI,SAAS,EAAE;IACtB,MAAMC,QAAQ,GAAGR,oBAAoB,CAACG,IAAI,EAAE;MAC1CE,QAAQ;MACRC;KACD,CAAC;IAEFJ,CAAC,CAACO,IAAI,CAACD,QAAQ,CAACE,OAAO,CAAC;IACxB,OAAOF,QAAQ,CAACG,KAAK;EACvB;EAEA,IAAI,CAACP,aAAa,EAAE;IAClBF,CAAC,CAACO,IAAI,CACJ,OAAOV,KAAK,CAACa,IAAI,CAAC,2DAA2D,CAAC,EAAE,CACjF;EACH;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import chalk from 'chalk';
2
+ export const maybeWarnAboutPlainStrings = (d, isPlainString) => {
3
+ if (!isPlainString) {
4
+ return;
5
+ }
6
+ d.push(`\r\n${chalk.gray('ℹ️ You used a plain string to represent a failure in the error channel (E). You should consider using tagged objects (with a _tag field), or yieldable errors such as Data.TaggedError and Schema.TaggedError for better handling experience.')}`);
7
+ };
8
+ //# sourceMappingURL=maybe-warn-about-plain-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe-warn-about-plain-strings.js","names":["chalk","maybeWarnAboutPlainStrings","d","isPlainString","push","gray"],"sources":["../../../../src/logic/pretty-printing/maybe-warn-about-plain-strings.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,0BAA0B,GAAGA,CACxCC,CAAW,EACXC,aAAsB,KACpB;EACF,IAAI,CAACA,aAAa,EAAE;IAClB;EACF;EAEAD,CAAC,CAACE,IAAI,CACJ,OAAOJ,KAAK,CAACK,IAAI,CAAC,gPAAgP,CAAC,EAAE,CACtQ;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import chalk from 'chalk';
2
+ import { filterStack } from '../stack/filter-stack';
3
+ export const printEffectStacktrace = (d, span, spanAttributesStack, {
4
+ stripCwd
5
+ }) => {
6
+ if (spanAttributesStack === undefined || spanAttributesStack.length === 0) {
7
+ return;
8
+ }
9
+ const cleanedStack = `│ ${filterStack(spanAttributesStack.join('\r\n│ '), stripCwd === true)}`;
10
+ d.push(`\r\n${span !== undefined ? '\r\n' : ''}🚨 Effect Stacktrace\r\n${chalk.red(cleanedStack)}`);
11
+ };
12
+ //# sourceMappingURL=print-effect-stacktrace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print-effect-stacktrace.js","names":["chalk","filterStack","printEffectStacktrace","d","span","spanAttributesStack","stripCwd","undefined","length","cleanedStack","join","push","red"],"sources":["../../../../src/logic/pretty-printing/print-effect-stacktrace.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAIzB,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,CAAW,EACXC,IAAsB,EACtBC,mBAAyC,EACzC;EAAEC;AAAQ,CAAsB,KAC9B;EACF,IAAID,mBAAmB,KAAKE,SAAS,IAAIF,mBAAmB,CAACG,MAAM,KAAK,CAAC,EAAE;IACzE;EACF;EAEA,MAAMC,YAAY,GAAG,KAAKR,WAAW,CAACI,mBAAmB,CAACK,IAAI,CAAC,QAAQ,CAAC,EAAEJ,QAAQ,KAAK,IAAI,CAAC,EAAE;EAC9FH,CAAC,CAACQ,IAAI,CACJ,OAAOP,IAAI,KAAKG,SAAS,GAAG,MAAM,GAAG,EAAE,2BAA2BP,KAAK,CAACY,GAAG,CAACH,YAAY,CAAC,EAAE,CAC5F;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ import chalk from 'chalk';
2
+ import { splitSpansAttributesByTypes } from './split-spans-attributes-by-type';
3
+ const maybePrintPipe = isLastEntry => isLastEntry ? ' ' : chalk.gray('│');
4
+ export const getSpanAttributes = (allAttributes, isLastEntry) => {
5
+ if (allAttributes.size === 0) {
6
+ return {
7
+ formattedAttributes: '',
8
+ stack: []
9
+ };
10
+ }
11
+ const {
12
+ attributes,
13
+ stacktrace
14
+ } = splitSpansAttributesByTypes(allAttributes);
15
+ const formattedAttributes = Array.from(attributes).map(([key, value]) => `${maybePrintPipe(isLastEntry)} ${chalk.blue(key)}${chalk.gray(':')} ${value}`).join('\r\n');
16
+ return {
17
+ formattedAttributes: `${formattedAttributes.length > 0 ? '\r\n' : ''}${formattedAttributes}`,
18
+ stack: stacktrace
19
+ };
20
+ };
21
+ //# sourceMappingURL=get-span-attributes.js.map
@@ -0,0 +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,kCAAkC;AAE9E,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":[]}
@@ -0,0 +1,9 @@
1
+ import chalk from 'chalk';
2
+ export const getSpanDuration = (status, isLastEntry) => {
3
+ if (status._tag !== 'Ended') {
4
+ return '';
5
+ }
6
+ const duration = (status.endTime - status.startTime) / BigInt(1000000);
7
+ return `\r\n${isLastEntry ? ' ' : chalk.gray('│')} ~ ${duration}ms`;
8
+ };
9
+ //# sourceMappingURL=get-span-duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-span-duration.js","names":["chalk","getSpanDuration","status","isLastEntry","_tag","duration","endTime","startTime","BigInt","gray"],"sources":["../../../../src/logic/spans/get-span-duration.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,OAAO,MAAMC,eAAe,GAAGA,CAACC,MAAkB,EAAEC,WAAoB,KAAI;EAC1E,IAAID,MAAM,CAACE,IAAI,KAAK,OAAO,EAAE;IAC3B,OAAO,EAAE;EACX;EAEA,MAAMC,QAAQ,GAAG,CAACH,MAAM,CAACI,OAAO,GAAGJ,MAAM,CAACK,SAAS,IAAIC,MAAM,CAAC,OAAO,CAAC;EAEtE,OAAO,OAAOL,WAAW,GAAG,GAAG,GAAGH,KAAK,CAACS,IAAI,CAAC,GAAG,CAAC,UAAUJ,QAAQ,IAAI;AACzE,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import chalk from 'chalk';
2
+ export const spanStackTrailingChar = isLastEntry => isLastEntry ? chalk.gray('╰') : chalk.gray('├');
3
+ //# sourceMappingURL=spans-stack-trailing-char.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spans-stack-trailing-char.js","names":["chalk","spanStackTrailingChar","isLastEntry","gray"],"sources":["../../../../src/logic/spans/spans-stack-trailing-char.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,qBAAqB,GAAIC,WAAoB,IACxDA,WAAW,GAAGF,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC,GAAGH,KAAK,CAACG,IAAI,CAAC,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ export const splitSpansAttributesByTypes = attributes => Array.from(attributes.entries()).reduce((prev, [key, value]) => {
2
+ if (key === 'code.stacktrace') {
3
+ return {
4
+ attributes: prev.attributes,
5
+ stacktrace: [...prev.stacktrace, value]
6
+ };
7
+ }
8
+ return {
9
+ attributes: new Map([...prev.attributes, [key, value]]),
10
+ stacktrace: prev.stacktrace
11
+ };
12
+ }, {
13
+ stacktrace: [],
14
+ attributes: new Map()
15
+ });
16
+ //# sourceMappingURL=split-spans-attributes-by-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"split-spans-attributes-by-type.js","names":["splitSpansAttributesByTypes","attributes","Array","from","entries","reduce","prev","key","value","stacktrace","Map"],"sources":["../../../../src/logic/spans/split-spans-attributes-by-type.ts"],"sourcesContent":[null],"mappings":"AAKA,OAAO,MAAMA,2BAA2B,GACtCC,UAAwC,IAExCC,KAAK,CAACC,IAAI,CAACF,UAAU,CAACG,OAAO,EAAE,CAAC,CAACC,MAAM,CACrC,CAACC,IAAI,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAI;EACrB,IAAID,GAAG,KAAK,iBAAiB,EAAE;IAC7B,OAAO;MACLN,UAAU,EAAEK,IAAI,CAACL,UAAU;MAC3BQ,UAAU,EAAE,CAAC,GAAGH,IAAI,CAACG,UAAU,EAAED,KAAK;KACvC;EACH;EAEA,OAAO;IACLP,UAAU,EAAE,IAAIS,GAAG,CAAC,CAAC,GAAGJ,IAAI,CAACL,UAAU,EAAE,CAACM,GAAG,EAAEC,KAAK,CAAC,CAAC,CAAC;IACvDC,UAAU,EAAEH,IAAI,CAACG;GAClB;AACH,CAAC,EACD;EACEA,UAAU,EAAE,EAAE;EACdR,UAAU,EAAE,IAAIS,GAAG;CACpB,CACF","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { stripCwdPath } from '../strip-cwd-path';
2
+ export const filterStack = (stack, stripCwd) => {
3
+ const lines = stack.split('\r\n');
4
+ const out = [];
5
+ for (const line of lines) {
6
+ out.push(line.replace(/at .*effect_cutpoint.*\((.*)\)/, 'at $1'));
7
+ if (line.includes('effect_cutpoint')) {
8
+ return out.join('\r\n');
9
+ }
10
+ }
11
+ const final = out.join('\r\n').replace(/ {4}at /g, '│ at ');
12
+ return stripCwd ? stripCwdPath(final) : final;
13
+ };
14
+ //# sourceMappingURL=filter-stack.js.map
@@ -0,0 +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,mBAAmB;AAEhD,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,CAAC,UAAU,EAAE,OAAO,CAAC;EAE3D,OAAON,QAAQ,GAAGH,YAAY,CAACY,KAAK,CAAC,GAAGA,KAAK;AAC/C,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ const cwdRegex = global.process !== undefined ? /*#__PURE__*/new RegExp( /*#__PURE__*/global.process.cwd(), 'g') : null;
2
+ export const stripCwdPath = path => cwdRegex === null ? path : path.replace(cwdRegex, '.');
3
+ //# sourceMappingURL=strip-cwd-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strip-cwd-path.js","names":["cwdRegex","global","process","undefined","RegExp","cwd","stripCwdPath","path","replace"],"sources":["../../../src/logic/strip-cwd-path.ts"],"sourcesContent":[null],"mappings":"AAAA,MAAMA,QAAQ,GACZC,MAAM,CAACC,OAAO,KAAKC,SAAS,gBAAG,IAAIC,MAAM,eAACH,MAAM,CAACC,OAAO,CAACG,GAAG,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI;AAE7E,OAAO,MAAMC,YAAY,GAAIC,IAAY,IACvCP,QAAQ,KAAK,IAAI,GAAGO,IAAI,GAAGA,IAAI,CAACC,OAAO,CAACR,QAAQ,EAAE,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ import chalk from 'chalk';
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';
10
+ export const prettyPrint = (cause, options = prettyPrintOptionsDefault) => {
11
+ if (isInterruptedOnly(cause)) {
12
+ return 'All fibers interrupted without errors.';
13
+ }
14
+ const failures = captureErrorsFrom(cause);
15
+ const title = `\r\n🫠 ${chalk.bold.yellowBright.underline(`${failures.length} error${failures.length > 1 ? 's' : ''} occured\r\n`)}\r\n`;
16
+ return title + failures.map(({
17
+ errorType,
18
+ message: errorMessage,
19
+ stack,
20
+ span,
21
+ isPlainString
22
+ }, failureIndex) => {
23
+ const d = [formatFailuresTitle(errorType, errorMessage, failures.length, failureIndex)];
24
+ maybeWarnAboutPlainStrings(d, isPlainString);
25
+ const spanAttributesStack = maybePrintSpanAttributes(d, span, isPlainString, options);
26
+ printEffectStacktrace(d, span, spanAttributesStack, options);
27
+ maybePrintNodeStacktrace(d, span, stack, isPlainString, options);
28
+ return [...d, '\r\n'].join('');
29
+ }).join('\r\n');
30
+ };
31
+ //# sourceMappingURL=pretty-print.js.map
@@ -0,0 +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,0CAA0C;AAC5E,SAASC,mBAAmB,QAAQ,+CAA+C;AACnF,SAASC,wBAAwB,QAAQ,qDAAqD;AAC9F,SAASC,wBAAwB,QAAQ,qDAAqD;AAC9F,SAASC,0BAA0B,QAAQ,wDAAwD;AACnG,SAASC,qBAAqB,QAAQ,iDAAiD;AACvF,SAEEC,yBAAyB,QACpB,mCAAmC;AAE1C,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":[]}
@@ -0,0 +1,11 @@
1
+ import { Effect, pipe } from 'effect';
2
+ import { prettyPrint } from '..';
3
+ import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type';
4
+ export const runPromise = async (effect, options = prettyPrintOptionsDefault) => await Effect.runPromise(pipe(effect, Effect.sandbox, Effect.catchAll(e => {
5
+ if (options.enabled === false) {
6
+ return Effect.fail(e);
7
+ }
8
+ console.error(prettyPrint(e, options));
9
+ return Effect.fail('❌ runPromise failure');
10
+ })));
11
+ //# sourceMappingURL=run-promise.js.map
@@ -0,0 +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,IAAI;AAChC,SAEEC,yBAAyB,QACpB,oCAAoC;AAE3C,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":[]}
@@ -0,0 +1,11 @@
1
+ import { Effect, pipe } from 'effect';
2
+ import { prettyPrint } from '..';
3
+ import { prettyPrintOptionsDefault } from '../types/pretty-print-options.type';
4
+ export const runSync = (effect, options = prettyPrintOptionsDefault) => Effect.runSync(pipe(effect, Effect.sandbox, Effect.catchAll(e => {
5
+ if (options.enabled === true) {
6
+ console.error(prettyPrint(e, options));
7
+ return Effect.fail('❌ runSync failure');
8
+ }
9
+ return Effect.fail(e);
10
+ })));
11
+ //# sourceMappingURL=run-sync.js.map
@@ -0,0 +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,IAAI;AAChC,SAEEC,yBAAyB,QACpB,oCAAoC;AAE3C,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,15 @@
1
+ export class PrettyError {
2
+ message;
3
+ stack;
4
+ span;
5
+ isPlainString;
6
+ errorType;
7
+ constructor(message, stack, span, isPlainString, errorType) {
8
+ this.message = message;
9
+ this.stack = stack;
10
+ this.span = span;
11
+ this.isPlainString = isPlainString;
12
+ this.errorType = errorType;
13
+ }
14
+ }
15
+ //# sourceMappingURL=pretty-error.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretty-error.type.js","names":["PrettyError","message","stack","span","isPlainString","errorType","constructor"],"sources":["../../../src/types/pretty-error.type.ts"],"sourcesContent":[null],"mappings":"AAEA,OAAM,MAAOA,WAAW;EAEXC,OAAA;EACAC,KAAA;EACAC,IAAA;EACAC,aAAA;EACAC,SAAA;EALXC,YACWL,OAAgB,EAChBC,KAAyB,EACzBC,IAAsB,EACtBC,aAAsB,EACtBC,SAAmB;IAJnB,KAAAJ,OAAO,GAAPA,OAAO;IACP,KAAAC,KAAK,GAALA,KAAK;IACL,KAAAC,IAAI,GAAJA,IAAI;IACJ,KAAAC,aAAa,GAAbA,aAAa;IACb,KAAAC,SAAS,GAATA,SAAS;EACjB","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ export const prettyPrintOptionsDefault = {
2
+ enabled: true,
3
+ stripCwd: false,
4
+ reverseSpans: true
5
+ };
6
+ //# sourceMappingURL=pretty-print-options.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pretty-print-options.type.js","names":["prettyPrintOptionsDefault","enabled","stripCwd","reverseSpans"],"sources":["../../../src/types/pretty-print-options.type.ts"],"sourcesContent":[null],"mappings":"AAMA,OAAO,MAAMA,yBAAyB,GAAuB;EAC3DC,OAAO,EAAE,IAAI;EACbC,QAAQ,EAAE,KAAK;EACfC,YAAY,EAAE;CACf","ignoreList":[]}
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "repository": "https://github.com/jpb06/effect-errors.git",
3
- "main": "index.js",
3
+ "main": "./cjs/index.js",
4
+ "module": "./esm/index.js",
5
+ "types": "./dts/index.d.ts",
4
6
  "name": "effect-errors",
5
- "version": "1.3.12",
7
+ "version": "1.4.2",
6
8
  "author": "jpb06 <jp.bois.06@outlook.fr>",
7
9
  "description": "A POC for errors reporting in Effect",
8
- "keywords": [],
10
+ "keywords": [
11
+ "effect"
12
+ ],
9
13
  "license": "MIT",
10
14
  "engines": {
11
15
  "node": "20.x"
@@ -14,7 +18,10 @@
14
18
  "update-deps": "bunx npm-check-updates --root --format group -i",
15
19
  "copy-package": "copyfiles package.json ./dist/",
16
20
  "copy-readme": "copyfiles README.md ./dist/",
17
- "build": "del-cli ./dist && tsc --project tsconfig-prod.json",
21
+ "build": "del-cli ./dist && bun build-esm && bun build-cjs && bun build-annotate",
22
+ "build-esm": "tsc -b tsconfig-prod.json",
23
+ "build-cjs": "babel dist/esm --plugins @babel/transform-export-namespace-from --plugins @babel/transform-modules-commonjs --out-dir dist/cjs --source-maps",
24
+ "build-annotate": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
18
25
  "postbuild": "bun run copy-package && bun run copy-readme",
19
26
  "lint": "eslint ./src",
20
27
  "type-check": "tsc --noEmit",
@@ -23,28 +30,34 @@
23
30
  "test-dev": "vitest --coverage",
24
31
  "test-coverage": "vitest run --coverage",
25
32
  "sync-icons": "bun generateReadmeIcons -h 50",
33
+ "run-example-tsx": "tsx ./src/examples/util/run",
26
34
  "run-example": "bun run ./src/examples/util/run",
27
35
  "run-examples": "bun run ./src/examples/util/run-all"
28
36
  },
29
37
  "dependencies": {
30
- "@effect/schema": "^0.67.3",
38
+ "@effect/schema": "^0.67.9",
31
39
  "chalk": "<5",
32
- "effect": "^3.1.5"
40
+ "effect": "^3.2.1"
33
41
  },
34
42
  "devDependencies": {
35
- "@eslint/eslintrc": "^3.0.2",
36
- "@eslint/js": "^9.2.0",
43
+ "@babel/cli": "^7.24.5",
44
+ "@babel/core": "^7.24.5",
45
+ "@babel/plugin-transform-export-namespace-from": "^7.24.1",
46
+ "@babel/plugin-transform-modules-commonjs": "^7.24.1",
47
+ "@eslint/eslintrc": "^3.1.0",
48
+ "@eslint/js": "^9.3.0",
37
49
  "@stylistic/eslint-plugin": "^2.1.0",
38
50
  "@stylistic/eslint-plugin-ts": "^2.1.0",
39
51
  "@types/eslint": "^8.56.10",
40
52
  "@types/fs-extra": "^11.0.4",
41
53
  "@types/node": "^20.12.12",
42
- "@typescript-eslint/eslint-plugin": "^7.9.0",
43
- "@typescript-eslint/parser": "^7.9.0",
54
+ "@typescript-eslint/eslint-plugin": "^7.10.0",
55
+ "@typescript-eslint/parser": "^7.10.0",
44
56
  "@vitest/coverage-v8": "^1.6.0",
57
+ "babel-plugin-annotate-pure-calls": "^0.4.0",
45
58
  "copyfiles": "^2.4.1",
46
59
  "del-cli": "^5.1.0",
47
- "eslint": "^9.2.0",
60
+ "eslint": "^9.3.0",
48
61
  "eslint-config-prettier": "^9.1.0",
49
62
  "eslint-config-standard-with-typescript": "^43.0.1",
50
63
  "eslint-import-resolver-typescript": "^3.6.1",
@@ -55,11 +68,13 @@
55
68
  "eslint-plugin-promise": "^6.1.1",
56
69
  "eslint-plugin-vitest": "^0.5.4",
57
70
  "fs-extra": "^11.2.0",
58
- "globals": "^15.2.0",
71
+ "globals": "^15.3.0",
59
72
  "prettier": "^3.2.5",
60
73
  "readme-package-icons": "^1.1.14",
61
- "typescript": "*",
62
- "typescript-eslint": "^7.9.0",
74
+ "ts-node": "^10.9.2",
75
+ "tsx": "^4.10.5",
76
+ "typescript": "^5.4.5",
77
+ "typescript-eslint": "^7.10.0",
63
78
  "vitest": "^1.6.0",
64
79
  "vitest-mock-extended": "^1.3.1"
65
80
  }
package/capture-errors.js DELETED
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.captureErrors = void 0;
4
- var effect_1 = require("effect");
5
- var Cause_1 = require("effect/Cause");
6
- var capture_errors_from_cause_1 = require("./logic/errors/capture-errors-from-cause");
7
- var strip_cwd_path_1 = require("./logic/strip-cwd-path");
8
- var captureErrors = function (cause, _a) {
9
- var _b = _a === void 0 ? {
10
- reverseSpans: true,
11
- stripCwd: true,
12
- } : _a, reverseSpans = _b.reverseSpans, stripCwd = _b.stripCwd;
13
- if ((0, Cause_1.isInterruptedOnly)(cause)) {
14
- return {
15
- interrupted: true,
16
- errors: [],
17
- };
18
- }
19
- var errors = (0, capture_errors_from_cause_1.captureErrorsFrom)(cause).map(function (_a) {
20
- var message = _a.message, maybeStack = _a.stack, span = _a.span, errorType = _a.errorType, isPlainString = _a.isPlainString;
21
- var spans = [];
22
- if (span !== undefined) {
23
- var current = span;
24
- while (current !== undefined && current._tag === 'Span') {
25
- var name_1 = current.name, attributes = current.attributes, status_1 = current.status;
26
- spans.push({
27
- name: name_1,
28
- attributes: attributes,
29
- status: status_1,
30
- });
31
- current = effect_1.Option.getOrUndefined(current.parent);
32
- }
33
- }
34
- var stack;
35
- if (maybeStack !== undefined) {
36
- stack = stripCwd === true ? (0, strip_cwd_path_1.stripCwdPath)(maybeStack) : maybeStack;
37
- }
38
- return {
39
- errorType: errorType,
40
- message: message,
41
- stack: stack,
42
- spans: reverseSpans === true ? spans.toReversed() : spans,
43
- isPlainString: isPlainString,
44
- };
45
- });
46
- return {
47
- interrupted: false,
48
- errors: errors,
49
- };
50
- };
51
- exports.captureErrors = captureErrors;
@@ -1 +0,0 @@
1
- export {};