effect-errors 1.0.3

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 ADDED
@@ -0,0 +1,53 @@
1
+ # effect-errors
2
+
3
+ <!-- readme-package-icons start -->
4
+
5
+ <p align="left"><a href="https://docs.github.com/en/actions" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg" /></a>&nbsp;<a href="https://www.typescriptlang.org/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg" /></a>&nbsp;<a href="https://nodejs.org/en/docs/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg" /></a>&nbsp;<a href="https://bun.sh/docs" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Bun-Dark.svg" /></a>&nbsp;<a href="https://github.com/motdotla/dotenv#readme" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Dotenv-Dark.svg" /></a>&nbsp;<a href="https://eslint.org/docs/latest/" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Eslint-Dark.svg" /></a>&nbsp;<a href="https://prettier.io/docs/en/index.html" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Prettier-Dark.svg" /></a>&nbsp;<a href="https://www.effect.website/docs/quickstart" target="_blank"><img height="50" src="https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Effect-Dark.svg" /></a></p>
6
+
7
+ <!-- readme-package-icons end -->
8
+
9
+ Some sort of POC to improve the way [Effect](https://effect.website/) reports errors in a dev env 🤔
10
+
11
+ ![example](./docs/parallel-errors-example.png)
12
+
13
+ ## ⚡ So how does it work?
14
+
15
+ Had to re-export `runSync` and `runPromise` to apply `prettyPrint` function on the cause returned by a `catchAll`.
16
+
17
+ So using it would look like this :
18
+
19
+ ```typescript
20
+ import { runPromise } from 'effect-errors';
21
+
22
+ (async () => {
23
+ await runPromise(
24
+ Effect.gen(function* (_) {
25
+ // ...
26
+ }),
27
+ );
28
+ })();
29
+ ```
30
+
31
+ The fancy logging behavior is enabled if your node env is `development` or if you set `EFFECT_PRETTY_PRINT` env var to `true`.
32
+
33
+ You can also directly import the `prettyPrint` function to do whatever you want with it if you want 🤷:
34
+
35
+ ```typescript
36
+ import { prettyPrint } from 'effect-errors';
37
+
38
+ // ...
39
+ ```
40
+
41
+ Signature is the following:
42
+
43
+ ```typescript
44
+ const prettyPrint: <E>(cause: Cause<E>) => string;
45
+ ```
46
+
47
+ ## ⚡ examples
48
+
49
+ I wrote some examples for fun and giggles. You can run them using:
50
+
51
+ ```bash
52
+ bun run-examples
53
+ ```
@@ -0,0 +1 @@
1
+ export declare const prettyPrintEnabled: boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prettyPrintEnabled = void 0;
4
+ var dotenv_flow_1 = require("dotenv-flow");
5
+ (0, dotenv_flow_1.config)();
6
+ exports.prettyPrintEnabled = process.env.NODE_ENV === 'development' ||
7
+ process.env.EFFECT_PRETTY_PRINT === 'true';
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './pretty-print';
2
+ export * from './runners/run-promise';
3
+ export * from './runners/run-sync';
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./pretty-print"), exports);
18
+ __exportStar(require("./runners/run-promise"), exports);
19
+ __exportStar(require("./runners/run-sync"), exports);
@@ -0,0 +1,2 @@
1
+ import { PrettyError } from '../types/pretty-error.type';
2
+ export declare const defaultRenderError: (error: unknown) => PrettyError;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultRenderError = void 0;
4
+ var Predicate_1 = require("effect/Predicate");
5
+ var pretty_error_type_1 = require("../types/pretty-error.type");
6
+ var pretty_error_message_1 = require("./pretty-error-message");
7
+ var spanSymbol = Symbol.for('effect/SpanAnnotation');
8
+ var defaultRenderError = function (error) {
9
+ var _a;
10
+ var span = ((0, Predicate_1.hasProperty)(error, spanSymbol) && error[spanSymbol]);
11
+ if (error instanceof Error) {
12
+ return new pretty_error_type_1.PrettyError((0, pretty_error_message_1.prettyErrorMessage)(error), (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n').filter(function (el) { return el.match(/at (.*)/); }).join('\n'), span);
13
+ }
14
+ return new pretty_error_type_1.PrettyError((0, pretty_error_message_1.prettyErrorMessage)(error), void 0, span);
15
+ };
16
+ exports.defaultRenderError = defaultRenderError;
@@ -0,0 +1 @@
1
+ export declare const filterStack: (stack: string) => string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.filterStack = void 0;
15
+ var filterStack = function (stack) {
16
+ var e_1, _a;
17
+ var lines = stack.split('\n');
18
+ var out = [];
19
+ try {
20
+ for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
21
+ var line = lines_1_1.value;
22
+ out.push(line.replace(/at .*effect_cutpoint.*\((.*)\)/, 'at $1'));
23
+ if (line.includes('effect_cutpoint')) {
24
+ return out.join('\n');
25
+ }
26
+ }
27
+ }
28
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
29
+ finally {
30
+ try {
31
+ if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
32
+ }
33
+ finally { if (e_1) throw e_1.error; }
34
+ }
35
+ return out.join('\n');
36
+ };
37
+ exports.filterStack = filterStack;
@@ -0,0 +1 @@
1
+ export declare const getSpanAttributes: (attributes: ReadonlyMap<string, unknown>, isLastEntry: boolean) => string;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.getSpanAttributes = void 0;
23
+ var chalk_1 = __importDefault(require("chalk"));
24
+ var getSpanAttributes = function (attributes, isLastEntry) {
25
+ if (attributes.size === 0) {
26
+ return '';
27
+ }
28
+ return "".concat("\r\n".concat(Array.from(attributes.entries())
29
+ .map(function (_a) {
30
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
31
+ return "".concat(isLastEntry ? ' ' : chalk_1.default.gray('│'), " ").concat(chalk_1.default.blue(key)).concat(chalk_1.default.gray(':'), " ").concat(value);
32
+ })
33
+ .join('\r\n')));
34
+ };
35
+ exports.getSpanAttributes = getSpanAttributes;
@@ -0,0 +1,2 @@
1
+ import { SpanStatus } from 'effect/Tracer';
2
+ export declare const getSpanDuration: (status: SpanStatus, isLastEntry: boolean) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getSpanDuration = void 0;
7
+ var chalk_1 = __importDefault(require("chalk"));
8
+ var getSpanDuration = function (status, isLastEntry) {
9
+ if (status._tag !== 'Ended') {
10
+ return '';
11
+ }
12
+ return "\r\n".concat(isLastEntry ? ' ' : chalk_1.default.gray('│'), " ~ ").concat((status.endTime - status.startTime) / BigInt(100000), "ms");
13
+ };
14
+ exports.getSpanDuration = getSpanDuration;
@@ -0,0 +1 @@
1
+ export declare const prettyErrorMessage: (u: unknown) => string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prettyErrorMessage = void 0;
7
+ var chalk_1 = __importDefault(require("chalk"));
8
+ var Function_1 = require("effect/Function");
9
+ var Predicate_1 = require("effect/Predicate");
10
+ var cwdRegex = new RegExp("".concat(process.cwd()), 'g');
11
+ var prettyErrorMessage = function (u) {
12
+ if (typeof u === 'string') {
13
+ return "Error: ".concat(u);
14
+ }
15
+ if ((0, Predicate_1.hasProperty)(u, 'toString') &&
16
+ (0, Function_1.isFunction)(u['toString']) &&
17
+ u['toString'] !== Object.prototype.toString &&
18
+ u['toString'] !== Array.prototype.toString) {
19
+ return u['toString']();
20
+ }
21
+ if ((0, Predicate_1.hasProperty)(u, '_tag') && (0, Predicate_1.hasProperty)(u, 'message')) {
22
+ var message = u.message
23
+ ? chalk_1.default
24
+ .hex('#c25c30')(u.message)
25
+ .replace(cwdRegex, '.')
26
+ : undefined;
27
+ return "\uD83D\uDCA5 ".concat(chalk_1.default.bgRed(" ".concat(u._tag, " ")), " ").concat(message ? "\u2022 ".concat(message) : '', "\r\n");
28
+ }
29
+ return "Error: ".concat(JSON.stringify(u));
30
+ };
31
+ exports.prettyErrorMessage = prettyErrorMessage;
@@ -0,0 +1,3 @@
1
+ import { Cause } from 'effect/Cause';
2
+ import { PrettyError } from '../types/pretty-error.type';
3
+ export declare const prettyErrors: <E>(cause: Cause<E>) => readonly PrettyError[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
18
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
+ if (ar || !(i in from)) {
21
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
+ ar[i] = from[i];
23
+ }
24
+ }
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
+ };
27
+ Object.defineProperty(exports, "__esModule", { value: true });
28
+ exports.prettyErrors = void 0;
29
+ var Cause_1 = require("effect/Cause");
30
+ var default_render_error_1 = require("./default-render-error");
31
+ var prettyErrors = function (cause) {
32
+ return (0, Cause_1.reduceWithContext)(cause, void 0, {
33
+ emptyCase: function () { return []; },
34
+ dieCase: function (_, unknownError) { return [(0, default_render_error_1.defaultRenderError)(unknownError)]; },
35
+ failCase: function (_, error) { return [(0, default_render_error_1.defaultRenderError)(error)]; },
36
+ interruptCase: function () { return []; },
37
+ parallelCase: function (_, l, r) { return __spreadArray(__spreadArray([], __read(l), false), __read(r), false); },
38
+ sequentialCase: function (_, l, r) { return __spreadArray(__spreadArray([], __read(l), false), __read(r), false); },
39
+ });
40
+ };
41
+ exports.prettyErrors = prettyErrors;
@@ -0,0 +1 @@
1
+ export declare const spanStackTrailingChar: (isLastEntry: boolean) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.spanStackTrailingChar = void 0;
7
+ var chalk_1 = __importDefault(require("chalk"));
8
+ var spanStackTrailingChar = function (isLastEntry) {
9
+ return isLastEntry ? chalk_1.default.gray('╰') : chalk_1.default.gray('├');
10
+ };
11
+ exports.spanStackTrailingChar = spanStackTrailingChar;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "repository": "https://github.com/jpb06/effect-errors.git",
3
+ "main": "dist/index.js",
4
+ "name": "effect-errors",
5
+ "version": "1.0.3",
6
+ "author": "jpb06 <jp.bois.06@outlook.fr>",
7
+ "description": "Getting user stats from github",
8
+ "keywords": [],
9
+ "license": "MIT",
10
+ "engines": {
11
+ "node": "20.x"
12
+ },
13
+ "scripts": {
14
+ "update-deps": "bunx npm-check-updates --root --format group -i",
15
+ "copy-package": "copyfiles package.json ./dist/",
16
+ "copy-readme": "copyfiles README.md ./dist/",
17
+ "build": "del-cli ./dist && tsc --project tsconfig-prod.json",
18
+ "postbuild": "bun run copy-package && bun run copy-readme",
19
+ "lint": "eslint ./src",
20
+ "type-check": "tsc --noEmit",
21
+ "sync-icons": "bun generateReadmeIcons -h 50",
22
+ "run-examples": "for i in ./src/examples/*.ts; do bun run $i; done"
23
+ },
24
+ "dependencies": {
25
+ "chalk": "^5.3.0",
26
+ "dotenv-flow": "^4.1.0",
27
+ "effect": "^2.4.1"
28
+ },
29
+ "devDependencies": {
30
+ "@stylistic/eslint-plugin": "^1.6.3",
31
+ "@types/eslint": "^8.56.5",
32
+ "@types/fs-extra": "^11.0.4",
33
+ "@types/node": "^20.11.24",
34
+ "@typescript-eslint/eslint-plugin": "^7.1.1",
35
+ "@typescript-eslint/parser": "^7.1.1",
36
+ "copyfiles": "^2.4.1",
37
+ "del-cli": "^5.1.0",
38
+ "eslint": "^8.57.0",
39
+ "eslint-config-prettier": "^9.1.0",
40
+ "eslint-import-resolver-typescript": "^3.6.1",
41
+ "eslint-plugin-import": "^2.29.1",
42
+ "eslint-plugin-markdown": "^3.0.1",
43
+ "eslint-plugin-prettier": "^5.1.3",
44
+ "fs-extra": "^11.2.0",
45
+ "prettier": "^3.2.5",
46
+ "readme-package-icons": "^1.1.14",
47
+ "typescript": "^5.0.0"
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ import { Cause } from 'effect/Cause';
2
+ export declare const prettyPrint: <E>(cause: Cause<E>) => string;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.prettyPrint = void 0;
7
+ var chalk_1 = __importDefault(require("chalk"));
8
+ var effect_1 = require("effect");
9
+ var Cause_1 = require("effect/Cause");
10
+ var filter_stack_1 = require("./logic/filter-stack");
11
+ var get_span_attributes_1 = require("./logic/get-span-attributes");
12
+ var get_span_duration_1 = require("./logic/get-span-duration");
13
+ var pretty_errors_1 = require("./logic/pretty-errors");
14
+ var spans_stack_trailing_char_1 = require("./logic/spans-stack-trailing-char");
15
+ var prettyPrint = function (cause) {
16
+ if ((0, Cause_1.isInterruptedOnly)(cause)) {
17
+ return 'All fibers interrupted without errors.';
18
+ }
19
+ var failures = (0, pretty_errors_1.prettyErrors)(cause);
20
+ console.error("\r\n\uD83E\uDEE0 ".concat(chalk_1.default.bold.yellowBright.underline("".concat(failures.length, " error").concat(failures.length > 1 ? 's' : '', " occurred\n"))));
21
+ return failures
22
+ .map(function (_a) {
23
+ var message = _a.message, stack = _a.stack, span = _a.span;
24
+ if (stack) {
25
+ message += "\r\n".concat((0, filter_stack_1.filterStack)(stack));
26
+ }
27
+ if (span) {
28
+ var current = span;
29
+ var spans_1 = [];
30
+ while (current && current._tag === 'Span') {
31
+ spans_1.push(current);
32
+ current = effect_1.Option.getOrUndefined(current.parent);
33
+ }
34
+ message += spans_1
35
+ .map(function (_a, index) {
36
+ var name = _a.name, attributes = _a.attributes, status = _a.status;
37
+ var isFirstEntry = index === 0;
38
+ var isLastEntry = index === spans_1.length - 1;
39
+ var filePath = " at ".concat(name.replace(new RegExp(process.cwd()), '.'));
40
+ return chalk_1.default.whiteBright((isFirstEntry ? "\r\n".concat(chalk_1.default.gray('◯')) : '') +
41
+ '\r\n' +
42
+ (0, spans_stack_trailing_char_1.spanStackTrailingChar)(isLastEntry) +
43
+ chalk_1.default.gray('─') +
44
+ filePath +
45
+ (0, get_span_duration_1.getSpanDuration)(status, isLastEntry) +
46
+ (0, get_span_attributes_1.getSpanAttributes)(attributes, isLastEntry));
47
+ })
48
+ .join('');
49
+ }
50
+ return message + '\r\n';
51
+ })
52
+ .join('\r\n');
53
+ };
54
+ exports.prettyPrint = prettyPrint;
@@ -0,0 +1,2 @@
1
+ import { Effect } from 'effect';
2
+ export declare const runPromise: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runPromise = void 0;
4
+ var effect_1 = require("effect");
5
+ var __1 = require("..");
6
+ var pretty_print_enabled_1 = require("../config/pretty-print-enabled");
7
+ var runPromise = function (effect) {
8
+ return effect_1.Effect.runPromise((0, effect_1.pipe)(effect, effect_1.Effect.sandbox, effect_1.Effect.catchAll(function (e) {
9
+ if (pretty_print_enabled_1.prettyPrintEnabled) {
10
+ console.error((0, __1.prettyPrint)(e));
11
+ return effect_1.Effect.fail('❌ runPromise failure');
12
+ }
13
+ return effect_1.Effect.fail(e);
14
+ })));
15
+ };
16
+ exports.runPromise = runPromise;
@@ -0,0 +1,2 @@
1
+ import { Effect } from 'effect';
2
+ export declare const runSync: <A, E>(effect: Effect.Effect<A, E, never>) => A;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runSync = void 0;
4
+ var effect_1 = require("effect");
5
+ var __1 = require("..");
6
+ var pretty_print_enabled_1 = require("../config/pretty-print-enabled");
7
+ var runSync = function (effect) {
8
+ return effect_1.Effect.runSync((0, effect_1.pipe)(effect, effect_1.Effect.sandbox, effect_1.Effect.catchAll(function (e) {
9
+ if (pretty_print_enabled_1.prettyPrintEnabled) {
10
+ console.error((0, __1.prettyPrint)(e));
11
+ return effect_1.Effect.fail('❌ runSync failure');
12
+ }
13
+ return effect_1.Effect.fail(e);
14
+ })));
15
+ };
16
+ exports.runSync = runSync;
@@ -0,0 +1,14 @@
1
+ import { Span } from 'effect/Tracer';
2
+ interface Error {
3
+ message: string;
4
+ stack?: string;
5
+ span?: Span;
6
+ }
7
+ export declare class PrettyError {
8
+ readonly message: string;
9
+ readonly stack: string | undefined;
10
+ readonly span: Span | undefined;
11
+ constructor(message: string, stack: string | undefined, span: Span | undefined);
12
+ toJSON(): Error;
13
+ }
14
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrettyError = void 0;
4
+ var PrettyError = /** @class */ (function () {
5
+ function PrettyError(message, stack, span) {
6
+ this.message = message;
7
+ this.stack = stack;
8
+ this.span = span;
9
+ }
10
+ PrettyError.prototype.toJSON = function () {
11
+ var out = { message: this.message };
12
+ if (this.stack) {
13
+ out.stack = this.stack;
14
+ }
15
+ if (this.span) {
16
+ out.span = this.span;
17
+ }
18
+ return out;
19
+ };
20
+ return PrettyError;
21
+ }());
22
+ exports.PrettyError = PrettyError;