effect-errors 1.3.4 → 1.3.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/README.md CHANGED
@@ -167,6 +167,7 @@ export interface CapturedErrors {
167
167
 
168
168
  export interface CaptureErrorsOptions {
169
169
  reverseSpans: boolean;
170
+ stripCwd: boolean;
170
171
  }
171
172
 
172
173
  type captureErrorsFunction: <E>(cause: Cause<E>, options: CaptureErrorsOptions) => CapturedErrors
@@ -189,6 +190,8 @@ await Effect.runPromise(
189
190
  );
190
191
  ```
191
192
 
193
+ ![alt text](./docs/remix-example.png)
194
+
192
195
  ## ⚡ examples
193
196
 
194
197
  I wrote some examples for fun and giggles. You can run them using:
@@ -18,5 +18,6 @@ export interface CapturedErrors {
18
18
  }
19
19
  export interface CaptureErrorsOptions {
20
20
  reverseSpans: boolean;
21
+ stripCwd: boolean;
21
22
  }
22
- export declare const captureErrors: <E>(cause: Cause<E>, { reverseSpans }?: CaptureErrorsOptions) => CapturedErrors;
23
+ export declare const captureErrors: <E>(cause: Cause<E>, { reverseSpans, stripCwd }?: CaptureErrorsOptions) => CapturedErrors;
package/capture-errors.js CHANGED
@@ -4,10 +4,12 @@ exports.captureErrors = void 0;
4
4
  var effect_1 = require("effect");
5
5
  var Cause_1 = require("effect/Cause");
6
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");
7
8
  var captureErrors = function (cause, _a) {
8
9
  var _b = _a === void 0 ? {
9
10
  reverseSpans: true,
10
- } : _a, reverseSpans = _b.reverseSpans;
11
+ stripCwd: true,
12
+ } : _a, reverseSpans = _b.reverseSpans, stripCwd = _b.stripCwd;
11
13
  if ((0, Cause_1.isInterruptedOnly)(cause)) {
12
14
  return {
13
15
  interrupted: true,
@@ -15,7 +17,7 @@ var captureErrors = function (cause, _a) {
15
17
  };
16
18
  }
17
19
  var errors = (0, capture_errors_from_cause_1.captureErrorsFrom)(cause).map(function (_a) {
18
- var message = _a.message, stack = _a.stack, span = _a.span, errorType = _a.errorType, isPlainString = _a.isPlainString;
20
+ var message = _a.message, maybeStack = _a.stack, span = _a.span, errorType = _a.errorType, isPlainString = _a.isPlainString;
19
21
  var spans = [];
20
22
  if (span !== undefined) {
21
23
  var current = span;
@@ -29,6 +31,10 @@ var captureErrors = function (cause, _a) {
29
31
  current = effect_1.Option.getOrUndefined(current.parent);
30
32
  }
31
33
  }
34
+ var stack;
35
+ if (maybeStack !== undefined) {
36
+ stack = stripCwd ? (0, strip_cwd_path_1.stripCwdPath)(maybeStack) : maybeStack;
37
+ }
32
38
  return {
33
39
  errorType: errorType,
34
40
  message: message,
@@ -53,7 +53,10 @@ void (0, console_mock_1.mockConsole)({
53
53
  case 0: return [4 /*yield*/, (0, effect_cause_1.effectCause)(from_promise_1.fromPromiseTask)];
54
54
  case 1:
55
55
  cause = _b.sent();
56
- result = (0, capture_errors_1.captureErrors)(cause, { reverseSpans: false });
56
+ result = (0, capture_errors_1.captureErrors)(cause, {
57
+ reverseSpans: false,
58
+ stripCwd: false,
59
+ });
57
60
  (0, vitest_1.expect)(result.interrupted).toBe(false);
58
61
  (0, vitest_1.expect)(result.errors).toHaveLength(1);
59
62
  _a = result.errors[0], errorType = _a.errorType, isPlainString = _a.isPlainString, message = _a.message, spans = _a.spans, stack = _a.stack;
@@ -83,7 +86,10 @@ void (0, console_mock_1.mockConsole)({
83
86
  case 0: return [4 /*yield*/, (0, effect_cause_1.effectCause)(parallel_errors_1.withParallelErrorsTask)];
84
87
  case 1:
85
88
  cause = _u.sent();
86
- result = (0, capture_errors_1.captureErrors)(cause, { reverseSpans: false });
89
+ result = (0, capture_errors_1.captureErrors)(cause, {
90
+ reverseSpans: false,
91
+ stripCwd: false,
92
+ });
87
93
  (0, vitest_1.expect)(result.interrupted).toBe(false);
88
94
  (0, vitest_1.expect)(result.errors).toHaveLength(3);
89
95
  firstError = result.errors[0];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "repository": "https://github.com/jpb06/effect-errors.git",
3
3
  "main": "index.js",
4
4
  "name": "effect-errors",
5
- "version": "1.3.4",
5
+ "version": "1.3.6",
6
6
  "author": "jpb06 <jp.bois.06@outlook.fr>",
7
7
  "description": "A POC for errors reporting in Effect",
8
8
  "keywords": [],
@@ -27,9 +27,9 @@
27
27
  "run-examples": "bun run ./src/examples/util/run-all"
28
28
  },
29
29
  "dependencies": {
30
- "@effect/schema": "^0.66.8",
30
+ "@effect/schema": "^0.66.10",
31
31
  "chalk": "<5",
32
- "effect": "^3.0.5"
32
+ "effect": "^3.0.7"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@eslint/eslintrc": "^3.0.2",
@@ -39,8 +39,8 @@
39
39
  "@types/eslint": "^8.56.10",
40
40
  "@types/fs-extra": "^11.0.4",
41
41
  "@types/node": "^20.12.7",
42
- "@typescript-eslint/eslint-plugin": "^7.7.1",
43
- "@typescript-eslint/parser": "^7.7.1",
42
+ "@typescript-eslint/eslint-plugin": "^7.8.0",
43
+ "@typescript-eslint/parser": "^7.8.0",
44
44
  "@vitest/coverage-v8": "^1.5.2",
45
45
  "copyfiles": "^2.4.1",
46
46
  "del-cli": "^5.1.0",
@@ -55,11 +55,11 @@
55
55
  "eslint-plugin-promise": "^6.1.1",
56
56
  "eslint-plugin-vitest": "^0.5.4",
57
57
  "fs-extra": "^11.2.0",
58
- "globals": "^15.0.0",
58
+ "globals": "^15.1.0",
59
59
  "prettier": "^3.2.5",
60
60
  "readme-package-icons": "^1.1.14",
61
61
  "typescript": "*",
62
- "typescript-eslint": "^7.7.1",
62
+ "typescript-eslint": "^7.8.0",
63
63
  "vitest": "^1.5.2",
64
64
  "vitest-mock-extended": "^1.3.1"
65
65
  }