effect-errors 1.2.1 → 1.2.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.
- package/logic/errors/capture-errors-from-cause.d.ts +3 -0
- package/logic/{pretty-errors.js → errors/capture-errors-from-cause.js} +6 -6
- package/logic/errors/parse-error.d.ts +2 -0
- package/logic/{default-render-error.js → errors/parse-error.js} +4 -4
- package/logic/{pretty-error-message.js → errors/pretty-error-message.js} +1 -0
- package/logic/{get-span-attributes.js → spans/get-span-attributes.js} +3 -2
- package/logic/{filter-stack.js → stack/filter-stack.js} +1 -1
- package/package.json +1 -1
- package/pretty-print.js +7 -6
- package/logic/default-render-error.d.ts +0 -2
- package/logic/pretty-errors.d.ts +0 -3
- /package/logic/{pretty-error-message.d.ts → errors/pretty-error-message.d.ts} +0 -0
- /package/logic/{get-span-attributes.d.ts → spans/get-span-attributes.d.ts} +0 -0
- /package/logic/{get-span-duration.d.ts → spans/get-span-duration.d.ts} +0 -0
- /package/logic/{get-span-duration.js → spans/get-span-duration.js} +0 -0
- /package/logic/{spans-stack-trailing-char.d.ts → spans/spans-stack-trailing-char.d.ts} +0 -0
- /package/logic/{spans-stack-trailing-char.js → spans/spans-stack-trailing-char.js} +0 -0
- /package/logic/{filter-stack.d.ts → stack/filter-stack.d.ts} +0 -0
|
@@ -25,17 +25,17 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
25
25
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
28
|
+
exports.captureErrorsFrom = void 0;
|
|
29
29
|
var Cause_1 = require("effect/Cause");
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var parse_error_1 = require("./parse-error");
|
|
31
|
+
var captureErrorsFrom = function (cause) {
|
|
32
32
|
return (0, Cause_1.reduceWithContext)(cause, void 0, {
|
|
33
33
|
emptyCase: function () { return []; },
|
|
34
|
-
dieCase: function (_, unknownError) { return [(0,
|
|
35
|
-
failCase: function (_, error) { return [(0,
|
|
34
|
+
dieCase: function (_, unknownError) { return [(0, parse_error_1.parseError)(unknownError)]; },
|
|
35
|
+
failCase: function (_, error) { return [(0, parse_error_1.parseError)(error)]; },
|
|
36
36
|
interruptCase: function () { return []; },
|
|
37
37
|
parallelCase: function (_, l, r) { return __spreadArray(__spreadArray([], __read(l), false), __read(r), false); },
|
|
38
38
|
sequentialCase: function (_, l, r) { return __spreadArray(__spreadArray([], __read(l), false), __read(r), false); },
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
|
-
exports.
|
|
41
|
+
exports.captureErrorsFrom = captureErrorsFrom;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseError = void 0;
|
|
4
4
|
var Predicate_1 = require("effect/Predicate");
|
|
5
|
-
var pretty_error_type_1 = require("
|
|
5
|
+
var pretty_error_type_1 = require("../../types/pretty-error.type");
|
|
6
6
|
var pretty_error_message_1 = require("./pretty-error-message");
|
|
7
7
|
var spanSymbol = Symbol.for('effect/SpanAnnotation');
|
|
8
|
-
var
|
|
8
|
+
var parseError = function (error) {
|
|
9
9
|
var _a;
|
|
10
10
|
var span = ((0, Predicate_1.hasProperty)(error, spanSymbol) && error[spanSymbol]);
|
|
11
11
|
if (error instanceof Error) {
|
|
@@ -13,4 +13,4 @@ var defaultRenderError = function (error) {
|
|
|
13
13
|
}
|
|
14
14
|
return new pretty_error_type_1.PrettyError((0, pretty_error_message_1.prettyErrorMessage)(error), void 0, span);
|
|
15
15
|
};
|
|
16
|
-
exports.
|
|
16
|
+
exports.parseError = parseError;
|
|
@@ -39,6 +39,7 @@ var prettyErrorMessage = function (u) {
|
|
|
39
39
|
if ((0, Predicate_1.hasProperty)(u, '_tag') && (0, Predicate_1.hasProperty)(u, 'message')) {
|
|
40
40
|
return "".concat(chalk_1.default.bgRed(" ".concat(u._tag, " ")), " ").concat(chalk_1.default.bold.whiteBright("\u2022 ".concat(u.message)), "\r\n");
|
|
41
41
|
}
|
|
42
|
+
// Plain objects with toString impl
|
|
42
43
|
if ((0, Predicate_1.hasProperty)(u, 'toString') &&
|
|
43
44
|
(0, Function_1.isFunction)(u['toString']) &&
|
|
44
45
|
u['toString'] !== Object.prototype.toString &&
|
|
@@ -25,11 +25,12 @@ var getSpanAttributes = function (attributes, isLastEntry) {
|
|
|
25
25
|
if (attributes.size === 0) {
|
|
26
26
|
return '';
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
var formattedAttributes = Array.from(attributes.entries())
|
|
29
29
|
.map(function (_a) {
|
|
30
30
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
31
31
|
return "".concat(isLastEntry ? ' ' : chalk_1.default.gray('│'), " ").concat(chalk_1.default.blue(key)).concat(chalk_1.default.gray(':'), " ").concat(value);
|
|
32
32
|
})
|
|
33
|
-
.join('\r\n')
|
|
33
|
+
.join('\r\n');
|
|
34
|
+
return "".concat("\r\n".concat(formattedAttributes));
|
|
34
35
|
};
|
|
35
36
|
exports.getSpanAttributes = getSpanAttributes;
|
|
@@ -12,7 +12,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.filterStack = void 0;
|
|
15
|
-
var strip_cwd_path_1 = require("
|
|
15
|
+
var strip_cwd_path_1 = require("../strip-cwd-path");
|
|
16
16
|
var filterStack = function (stack, stripCwd) {
|
|
17
17
|
var e_1, _a;
|
|
18
18
|
var lines = stack.split('\n');
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"repository": "https://github.com/jpb06/effect-errors.git",
|
|
3
3
|
"main": "dist/index.js",
|
|
4
4
|
"name": "effect-errors",
|
|
5
|
-
"version": "1.2.
|
|
5
|
+
"version": "1.2.2",
|
|
6
6
|
"author": "jpb06 <jp.bois.06@outlook.fr>",
|
|
7
7
|
"description": "A POC for errors reporting in Effect",
|
|
8
8
|
"keywords": [],
|
package/pretty-print.js
CHANGED
|
@@ -7,11 +7,11 @@ exports.prettyPrint = void 0;
|
|
|
7
7
|
var chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
var effect_1 = require("effect");
|
|
9
9
|
var Cause_1 = require("effect/Cause");
|
|
10
|
-
var
|
|
11
|
-
var get_span_attributes_1 = require("./logic/get-span-attributes");
|
|
12
|
-
var get_span_duration_1 = require("./logic/get-span-duration");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
10
|
+
var capture_errors_from_cause_1 = require("./logic/errors/capture-errors-from-cause");
|
|
11
|
+
var get_span_attributes_1 = require("./logic/spans/get-span-attributes");
|
|
12
|
+
var get_span_duration_1 = require("./logic/spans/get-span-duration");
|
|
13
|
+
var spans_stack_trailing_char_1 = require("./logic/spans/spans-stack-trailing-char");
|
|
14
|
+
var filter_stack_1 = require("./logic/stack/filter-stack");
|
|
15
15
|
var strip_cwd_path_1 = require("./logic/strip-cwd-path");
|
|
16
16
|
var pretty_print_options_type_1 = require("./types/pretty-print-options.type");
|
|
17
17
|
var prettyPrint = function (cause, _a) {
|
|
@@ -19,7 +19,7 @@ var prettyPrint = function (cause, _a) {
|
|
|
19
19
|
if ((0, Cause_1.isInterruptedOnly)(cause)) {
|
|
20
20
|
return 'All fibers interrupted without errors.';
|
|
21
21
|
}
|
|
22
|
-
var failures = (0,
|
|
22
|
+
var failures = (0, capture_errors_from_cause_1.captureErrorsFrom)(cause);
|
|
23
23
|
console.error("\r\n\uD83E\uDEE0 ".concat(chalk_1.default.bold.yellowBright.underline("".concat(failures.length, " error").concat(failures.length > 1 ? 's' : '', " occurred\n"))));
|
|
24
24
|
return failures
|
|
25
25
|
.map(function (_a, failuresIndex) {
|
|
@@ -38,6 +38,7 @@ var prettyPrint = function (cause, _a) {
|
|
|
38
38
|
: '') +
|
|
39
39
|
message +
|
|
40
40
|
spans_1
|
|
41
|
+
.reverse()
|
|
41
42
|
.map(function (_a, index) {
|
|
42
43
|
var name = _a.name, attributes = _a.attributes, status = _a.status;
|
|
43
44
|
var isFirstEntry = index === 0;
|
package/logic/pretty-errors.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|