effect-errors 1.4.12 → 1.5.0
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 +1 -1
- package/cjs/capture-errors.js +6 -54
- package/cjs/capture-errors.js.map +1 -1
- package/cjs/index.js +11 -0
- package/cjs/index.js.map +1 -1
- package/cjs/logic/effects/fs/fs-error.js +10 -0
- package/cjs/logic/effects/fs/fs-error.js.map +1 -0
- package/cjs/logic/effects/fs/fs-extra.effects.js +50 -0
- package/cjs/logic/effects/fs/fs-extra.effects.js.map +1 -0
- package/cjs/logic/stack/stack-regex.js +2 -3
- package/cjs/logic/stack/stack-regex.js.map +1 -1
- package/cjs/logic/util/big-int-replacer.js +17 -0
- package/cjs/logic/util/big-int-replacer.js.map +1 -0
- package/cjs/source-maps/get-error-location-from-file-path.js +23 -0
- package/cjs/source-maps/get-error-location-from-file-path.js.map +1 -0
- package/cjs/source-maps/get-error-related-sources.js +33 -0
- package/cjs/source-maps/get-error-related-sources.js.map +1 -0
- package/cjs/source-maps/get-source-code.js +28 -0
- package/cjs/source-maps/get-source-code.js.map +1 -0
- package/cjs/source-maps/get-sources-from-map-file.js +50 -0
- package/cjs/source-maps/get-sources-from-map-file.js.map +1 -0
- package/cjs/source-maps/maybe-map-sourcemaps.js +13 -10
- package/cjs/source-maps/maybe-map-sourcemaps.js.map +1 -1
- package/cjs/source-maps/transform-raw-error.js +60 -0
- package/cjs/source-maps/transform-raw-error.js.map +1 -0
- package/dts/capture-errors.d.ts +5 -3
- package/dts/capture-errors.d.ts.map +1 -1
- package/dts/index.d.ts +2 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/logic/effects/fs/fs-error.d.ts +10 -0
- package/dts/logic/effects/fs/fs-error.d.ts.map +1 -0
- package/dts/logic/effects/fs/fs-extra.effects.d.ts +6 -0
- package/dts/logic/effects/fs/fs-extra.effects.d.ts.map +1 -0
- package/dts/logic/stack/stack-regex.d.ts +1 -2
- package/dts/logic/stack/stack-regex.d.ts.map +1 -1
- package/dts/logic/util/big-int-replacer.d.ts +2 -0
- package/dts/logic/util/big-int-replacer.d.ts.map +1 -0
- package/dts/source-maps/get-error-location-from-file-path.d.ts +7 -0
- package/dts/source-maps/get-error-location-from-file-path.d.ts.map +1 -0
- package/dts/source-maps/get-error-related-sources.d.ts +5 -0
- package/dts/source-maps/get-error-related-sources.d.ts.map +1 -0
- package/dts/source-maps/get-source-code.d.ts +10 -0
- package/dts/source-maps/get-source-code.d.ts.map +1 -0
- package/dts/source-maps/get-sources-from-map-file.d.ts +11 -0
- package/dts/source-maps/get-sources-from-map-file.d.ts.map +1 -0
- package/dts/source-maps/maybe-map-sourcemaps.d.ts +4 -2
- package/dts/source-maps/maybe-map-sourcemaps.d.ts.map +1 -1
- package/dts/source-maps/transform-raw-error.d.ts +17 -0
- package/dts/source-maps/transform-raw-error.d.ts.map +1 -0
- package/dts/types/pretty-error.type.d.ts +2 -2
- package/dts/types/pretty-error.type.d.ts.map +1 -1
- package/esm/capture-errors.js +7 -55
- package/esm/capture-errors.js.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/logic/effects/fs/fs-error.js +3 -0
- package/esm/logic/effects/fs/fs-error.js.map +1 -0
- package/esm/logic/effects/fs/fs-extra.effects.js +36 -0
- package/esm/logic/effects/fs/fs-extra.effects.js.map +1 -0
- package/esm/logic/stack/stack-regex.js +1 -2
- package/esm/logic/stack/stack-regex.js.map +1 -1
- package/esm/logic/util/big-int-replacer.js +10 -0
- package/esm/logic/util/big-int-replacer.js.map +1 -0
- package/esm/source-maps/get-error-location-from-file-path.js +16 -0
- package/esm/source-maps/get-error-location-from-file-path.js.map +1 -0
- package/esm/source-maps/get-error-related-sources.js +26 -0
- package/esm/source-maps/get-error-related-sources.js.map +1 -0
- package/esm/source-maps/get-source-code.js +21 -0
- package/esm/source-maps/get-source-code.js.map +1 -0
- package/esm/source-maps/get-sources-from-map-file.js +38 -0
- package/esm/source-maps/get-sources-from-map-file.js.map +1 -0
- package/esm/source-maps/maybe-map-sourcemaps.js +14 -11
- package/esm/source-maps/maybe-map-sourcemaps.js.map +1 -1
- package/esm/source-maps/transform-raw-error.js +53 -0
- package/esm/source-maps/transform-raw-error.js.map +1 -0
- package/package.json +32 -28
- package/cjs/source-maps/get-source-excerpt.js +0 -46
- package/cjs/source-maps/get-source-excerpt.js.map +0 -1
- package/cjs/source-maps/get-ts-code-from-sourcemap.js +0 -58
- package/cjs/source-maps/get-ts-code-from-sourcemap.js.map +0 -1
- package/cjs/source-maps/insert-into.js +0 -9
- package/cjs/source-maps/insert-into.js.map +0 -1
- package/dts/source-maps/get-source-excerpt.d.ts +0 -2
- package/dts/source-maps/get-source-excerpt.d.ts.map +0 -1
- package/dts/source-maps/get-ts-code-from-sourcemap.d.ts +0 -6
- package/dts/source-maps/get-ts-code-from-sourcemap.d.ts.map +0 -1
- package/dts/source-maps/insert-into.d.ts +0 -2
- package/dts/source-maps/insert-into.d.ts.map +0 -1
- package/esm/source-maps/get-source-excerpt.js +0 -34
- package/esm/source-maps/get-source-excerpt.js.map +0 -1
- package/esm/source-maps/get-ts-code-from-sourcemap.js +0 -46
- package/esm/source-maps/get-ts-code-from-sourcemap.js.map +0 -1
- package/esm/source-maps/insert-into.js +0 -2
- package/esm/source-maps/insert-into.js.map +0 -1
- package/package.json.bak +0 -94
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-error-location-from-file-path.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-error-location-from-file-path.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,oBAAoB,eACnB,MAAM,KACjB,aAAa,GAAG,SAWlB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type FsError } from '../logic/effects/fs/fs-error.js';
|
|
3
|
+
import { type ErrorRelatedSources } from './get-sources-from-map-file.js';
|
|
4
|
+
export declare const getErrorRelatedSources: (sourceFile: string) => Effect.Effect<ErrorRelatedSources | undefined, FsError>;
|
|
5
|
+
//# sourceMappingURL=get-error-related-sources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-error-related-sources.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-error-related-sources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAI/D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,gCAAgC,CAAC;AAExC,eAAO,MAAM,sBAAsB,eACrB,MAAM,KACjB,MAAM,CAAC,MAAM,CAAC,mBAAmB,GAAG,SAAS,EAAE,OAAO,CAqBrD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type FsError } from '../logic/effects/fs/fs-error.js';
|
|
3
|
+
import { type ErrorLocation } from './get-error-location-from-file-path.js';
|
|
4
|
+
export interface SourceCode {
|
|
5
|
+
line: number;
|
|
6
|
+
code: string;
|
|
7
|
+
column: number | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare const getSourceCode: ({ filePath, line, column }: ErrorLocation, isFromJs?: boolean) => Effect.Effect<SourceCode[], FsError>;
|
|
10
|
+
//# sourceMappingURL=get-source-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-source-code.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-source-code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAG/D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAID,eAAO,MAAM,aAAa,+BACI,aAAa,yBAExC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,CAoBlC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type FsError } from '../logic/effects/fs/fs-error.js';
|
|
3
|
+
import { type ErrorLocation } from './get-error-location-from-file-path.js';
|
|
4
|
+
import { type SourceCode } from './get-source-code.js';
|
|
5
|
+
export interface ErrorRelatedSources {
|
|
6
|
+
source: SourceCode[] | undefined;
|
|
7
|
+
runPath: string;
|
|
8
|
+
sourcesPath: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare const getSourcesFromMapFile: (location: ErrorLocation) => Effect.Effect<ErrorRelatedSources | undefined, FsError>;
|
|
11
|
+
//# sourceMappingURL=get-sources-from-map-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-sources-from-map-file.d.ts","sourceRoot":"","sources":["../../../src/source-maps/get-sources-from-map-file.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAM/D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,UAAU,EAAE,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,eAAO,MAAM,qBAAqB,aACtB,aAAa,KACtB,MAAM,CAAC,MAAM,CAAC,mBAAmB,GAAG,SAAS,EAAE,OAAO,CAmDrD,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type FsError } from '../logic/effects/fs/fs-error.js';
|
|
3
|
+
import { type ErrorRelatedSources } from './get-sources-from-map-file.js';
|
|
4
|
+
export declare const maybeMapSourcemaps: (stacktrace: string[]) => Effect.Effect<ErrorRelatedSources[], FsError>;
|
|
3
5
|
//# sourceMappingURL=maybe-map-sourcemaps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe-map-sourcemaps.d.ts","sourceRoot":"","sources":["../../../src/source-maps/maybe-map-sourcemaps.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"maybe-map-sourcemaps.d.ts","sourceRoot":"","sources":["../../../src/source-maps/maybe-map-sourcemaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAI/D,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,eAAO,MAAM,kBAAkB,eACjB,MAAM,EAAE,KACnB,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,EAAE,OAAO,CAwB5C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { type CaptureErrorsOptions } from '../capture-errors.js';
|
|
3
|
+
import { type PrettyError } from '../types/pretty-error.type.js';
|
|
4
|
+
import { type ErrorRelatedSources } from './get-sources-from-map-file.js';
|
|
5
|
+
export declare const transformRawError: ({ reverseSpans, stripCwd }: CaptureErrorsOptions) => ({ message, stack: maybeStack, span, errorType, isPlainString, }: PrettyError) => Effect.Effect<{
|
|
6
|
+
errorType: unknown;
|
|
7
|
+
message: unknown;
|
|
8
|
+
stack: string[] | undefined;
|
|
9
|
+
sources: ErrorRelatedSources[] | undefined;
|
|
10
|
+
spans: {
|
|
11
|
+
name: string;
|
|
12
|
+
attributes: ReadonlyMap<string, unknown>;
|
|
13
|
+
status: import("effect/Tracer").SpanStatus;
|
|
14
|
+
}[];
|
|
15
|
+
isPlainString: boolean;
|
|
16
|
+
}, import("../logic/effects/fs/fs-error.js").FsError, never>;
|
|
17
|
+
//# sourceMappingURL=transform-raw-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-raw-error.d.ts","sourceRoot":"","sources":["../../../src/source-maps/transform-raw-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAIjE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAG1E,eAAO,MAAM,iBAAiB,+BACC,oBAAoB,uEAO9C,WAAW;;;;;;;;;;;4DAuCV,CAAC"}
|
|
@@ -4,7 +4,7 @@ export declare class PrettyError {
|
|
|
4
4
|
readonly stack: string | undefined;
|
|
5
5
|
readonly span: Span | undefined;
|
|
6
6
|
readonly isPlainString: boolean;
|
|
7
|
-
readonly errorType?: unknown
|
|
8
|
-
constructor(message: unknown, stack: string | undefined, span: Span | undefined, isPlainString: boolean, errorType?: unknown
|
|
7
|
+
readonly errorType?: unknown;
|
|
8
|
+
constructor(message: unknown, stack: string | undefined, span: Span | undefined, isPlainString: boolean, errorType?: unknown);
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=pretty-error.type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pretty-error.type.d.ts","sourceRoot":"","sources":["../../../src/types/pretty-error.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,qBAAa,WAAW;IAEpB,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO;gBAJnB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,aAAa,EAAE,OAAO,EACtB,SAAS,CAAC,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"pretty-error.type.d.ts","sourceRoot":"","sources":["../../../src/types/pretty-error.type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,qBAAa,WAAW;IAEpB,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO;gBAJnB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,aAAa,EAAE,OAAO,EACtB,SAAS,CAAC,EAAE,OAAO;CAE/B"}
|
package/esm/capture-errors.js
CHANGED
|
@@ -1,70 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
2
|
import { isInterruptedOnly } from 'effect/Cause';
|
|
3
3
|
import { captureErrorsFrom } from './logic/errors/capture-errors-from-cause.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { stripCwdPath } from './logic/strip-cwd-path.js';
|
|
7
|
-
import { maybeMapSourcemaps } from './source-maps/maybe-map-sourcemaps.js';
|
|
8
|
-
export const captureErrors = async (cause, {
|
|
9
|
-
reverseSpans,
|
|
10
|
-
stripCwd
|
|
11
|
-
} = {
|
|
4
|
+
import { transformRawError } from './source-maps/transform-raw-error.js';
|
|
5
|
+
export const captureErrors = (cause, options = {
|
|
12
6
|
reverseSpans: true,
|
|
13
7
|
stripCwd: true
|
|
14
|
-
}) => {
|
|
8
|
+
}) => Effect.gen(function* () {
|
|
15
9
|
if (isInterruptedOnly(cause)) {
|
|
16
10
|
return {
|
|
17
11
|
interrupted: true,
|
|
18
12
|
errors: []
|
|
19
13
|
};
|
|
20
14
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
stack: maybeStack,
|
|
24
|
-
span,
|
|
25
|
-
errorType,
|
|
26
|
-
isPlainString
|
|
27
|
-
}) => {
|
|
28
|
-
const effectStacktrace = [];
|
|
29
|
-
const spans = [];
|
|
30
|
-
if (span !== undefined) {
|
|
31
|
-
let current = span;
|
|
32
|
-
while (current !== undefined && current._tag === 'Span') {
|
|
33
|
-
const {
|
|
34
|
-
name,
|
|
35
|
-
attributes: allAttributes,
|
|
36
|
-
status
|
|
37
|
-
} = current;
|
|
38
|
-
const {
|
|
39
|
-
attributes,
|
|
40
|
-
stacktrace
|
|
41
|
-
} = splitSpansAttributesByTypes(allAttributes);
|
|
42
|
-
const stacktraceWithMaybeSources = await maybeMapSourcemaps(stacktrace);
|
|
43
|
-
effectStacktrace.push(...stacktraceWithMaybeSources);
|
|
44
|
-
spans.push({
|
|
45
|
-
name,
|
|
46
|
-
attributes,
|
|
47
|
-
status
|
|
48
|
-
});
|
|
49
|
-
current = Option.getOrUndefined(current.parent);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
let stack;
|
|
53
|
-
if (maybeStack !== undefined) {
|
|
54
|
-
stack = stripCwd === true ? stripCwdPath(maybeStack) : maybeStack;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
errorType,
|
|
58
|
-
message,
|
|
59
|
-
stack: stack?.replaceAll(stackAtRegex, 'at ').split('\r\n'),
|
|
60
|
-
effectStacktrace: effectStacktrace.length > 0 ? effectStacktrace : undefined,
|
|
61
|
-
spans: reverseSpans === true ? spans.toReversed() : spans,
|
|
62
|
-
isPlainString
|
|
63
|
-
};
|
|
64
|
-
}));
|
|
15
|
+
const rawErrors = captureErrorsFrom(cause);
|
|
16
|
+
const errors = yield* Effect.forEach(rawErrors, transformRawError(options));
|
|
65
17
|
return {
|
|
66
18
|
interrupted: false,
|
|
67
19
|
errors
|
|
68
20
|
};
|
|
69
|
-
};
|
|
21
|
+
});
|
|
70
22
|
//# sourceMappingURL=capture-errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-errors.js","names":["
|
|
1
|
+
{"version":3,"file":"capture-errors.js","names":["Effect","isInterruptedOnly","captureErrorsFrom","transformRawError","captureErrors","cause","options","reverseSpans","stripCwd","gen","interrupted","errors","rawErrors","forEach"],"sources":["../../src/capture-errors.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAC/B,SAAqBC,iBAAiB,QAAQ,cAAc;AAI5D,SAASC,iBAAiB,QAAQ,6CAA6C;AAE/E,SAASC,iBAAiB,QAAQ,sCAAsC;AA2BxE,OAAO,MAAMC,aAAa,GAAGA,CAC3BC,KAAe,EACfC,OAAA,GAAgC;EAC9BC,YAAY,EAAE,IAAI;EAClBC,QAAQ,EAAE;CACX,KAEDR,MAAM,CAACS,GAAG,CAAC,aAAS;EAClB,IAAIR,iBAAiB,CAACI,KAAK,CAAC,EAAE;IAC5B,OAAO;MACLK,WAAW,EAAE,IAAI;MACjBC,MAAM,EAAE;KACT;EACH;EAEA,MAAMC,SAAS,GAAGV,iBAAiB,CAAIG,KAAK,CAAC;EAC7C,MAAMM,MAAM,GAAG,OAAOX,MAAM,CAACa,OAAO,CAACD,SAAS,EAAET,iBAAiB,CAACG,OAAO,CAAC,CAAC;EAE3E,OAAO;IACLI,WAAW,EAAE,KAAK;IAClBC;GACD;AACH,CAAC,CAAC","ignoreList":[]}
|
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,0BAA0B;AACxC,cAAc,uBAAuB;AACrC,cAAc,sCAAsC;AACpD,cAAc,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,0BAA0B;AACxC,cAAc,uBAAuB;AACrC,cAAc,sCAAsC;AACpD,cAAc,qBAAqB;AACnC,cAAc,kCAAkC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-error.js","names":["TaggedError","FsError"],"sources":["../../../../../src/logic/effects/fs/fs-error.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAM,MAAOC,OAAQ,SAAQD,WAAW,CAAC,UAAU,CAGjD","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Effect, pipe } from 'effect';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { FsError } from './fs-error.js';
|
|
4
|
+
export const readFileEffect = path => pipe(Effect.tryPromise({
|
|
5
|
+
try: async () => await fs.readFile(path, {
|
|
6
|
+
encoding: 'utf8'
|
|
7
|
+
}),
|
|
8
|
+
catch: e => new FsError({
|
|
9
|
+
cause: e
|
|
10
|
+
})
|
|
11
|
+
}), Effect.withSpan('readFile', {
|
|
12
|
+
attributes: {
|
|
13
|
+
path
|
|
14
|
+
}
|
|
15
|
+
}));
|
|
16
|
+
export const existsEffect = path => pipe(Effect.tryPromise({
|
|
17
|
+
try: async () => await fs.exists(path),
|
|
18
|
+
catch: e => new FsError({
|
|
19
|
+
cause: e
|
|
20
|
+
})
|
|
21
|
+
}), Effect.withSpan('exists', {
|
|
22
|
+
attributes: {
|
|
23
|
+
path
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
export const readJsonEffect = path => pipe(Effect.tryPromise({
|
|
27
|
+
try: async () => await fs.readJson(path),
|
|
28
|
+
catch: e => new FsError({
|
|
29
|
+
cause: e
|
|
30
|
+
})
|
|
31
|
+
}), Effect.withSpan('readJson', {
|
|
32
|
+
attributes: {
|
|
33
|
+
path
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
//# sourceMappingURL=fs-extra.effects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-extra.effects.js","names":["Effect","pipe","fs","FsError","readFileEffect","path","tryPromise","try","readFile","encoding","catch","e","cause","withSpan","attributes","existsEffect","exists","readJsonEffect","readJson"],"sources":["../../../../../src/logic/effects/fs/fs-extra.effects.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AACrC,OAAOC,EAAE,MAAM,UAAU;AAEzB,SAASC,OAAO,QAAQ,eAAe;AAEvC,OAAO,MAAMC,cAAc,GAAIC,IAAY,IACzCJ,IAAI,CACFD,MAAM,CAACM,UAAU,CAAC;EAChBC,GAAG,EAAE,MAAAA,CAAA,KAAY,MAAML,EAAE,CAACM,QAAQ,CAACH,IAAI,EAAE;IAAEI,QAAQ,EAAE;EAAM,CAAE,CAAC;EAC9DC,KAAK,EAAGC,CAAC,IAAK,IAAIR,OAAO,CAAC;IAAES,KAAK,EAAED;EAAC,CAAE;CACvC,CAAC,EACFX,MAAM,CAACa,QAAQ,CAAC,UAAU,EAAE;EAAEC,UAAU,EAAE;IAAET;EAAI;AAAE,CAAE,CAAC,CACtD;AAEH,OAAO,MAAMU,YAAY,GAAIV,IAAY,IACvCJ,IAAI,CACFD,MAAM,CAACM,UAAU,CAAC;EAChBC,GAAG,EAAE,MAAAA,CAAA,KAAY,MAAML,EAAE,CAACc,MAAM,CAACX,IAAI,CAAC;EACtCK,KAAK,EAAGC,CAAC,IAAK,IAAIR,OAAO,CAAC;IAAES,KAAK,EAAED;EAAC,CAAE;CACvC,CAAC,EACFX,MAAM,CAACa,QAAQ,CAAC,QAAQ,EAAE;EAAEC,UAAU,EAAE;IAAET;EAAI;AAAE,CAAE,CAAC,CACpD;AAEH,OAAO,MAAMY,cAAc,GAAaZ,IAAY,IAClDJ,IAAI,CACFD,MAAM,CAACM,UAAU,CAAC;EAChBC,GAAG,EAAE,MAAAA,CAAA,KAAY,MAAOL,EAAE,CAACgB,QAAQ,CAACb,IAAI,CAAsB;EAC9DK,KAAK,EAAGC,CAAC,IAAK,IAAIR,OAAO,CAAC;IAAES,KAAK,EAAED;EAAC,CAAE;CACvC,CAAC,EACFX,MAAM,CAACa,QAAQ,CAAC,UAAU,EAAE;EAAEC,UAAU,EAAE;IAAET;EAAI;AAAE,CAAE,CAAC,CACtD","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export const stackLineRegex = /^ {4}at .*\((.*)\)$/g;
|
|
2
1
|
export const stackAtRegex = / {4}at /g;
|
|
3
|
-
export const
|
|
2
|
+
export const sourceFileWithMapPointerRegex = /^(file:\/\/)?(.*.([jt])s)(\?.*)?:(\d*):(\d*)$/;
|
|
4
3
|
//# sourceMappingURL=stack-regex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack-regex.js","names":["
|
|
1
|
+
{"version":3,"file":"stack-regex.js","names":["stackAtRegex","sourceFileWithMapPointerRegex"],"sources":["../../../../src/logic/stack/stack-regex.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,YAAY,GAAG,UAAU;AACtC,OAAO,MAAMC,6BAA6B,GACxC,+CAA+C","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"big-int-replacer.js","names":["bigIntReplacer","key","value","type","toString"],"sources":["../../../../src/logic/util/big-int-replacer.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAGA,CAACC,GAAW,EAAEC,KAAc,KAAI;EAC5D,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO;MACLC,IAAI,EAAE,QAAQ;MACdD,KAAK,EAAEA,KAAK,CAACE,QAAQ;KACtB;EACH;EACA,OAAOF,KAAK;AACd,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sourceFileWithMapPointerRegex } from '../logic/stack/stack-regex.js';
|
|
2
|
+
export const getErrorLocationFrom = sourceFile => {
|
|
3
|
+
const regex = sourceFileWithMapPointerRegex.exec(sourceFile);
|
|
4
|
+
if (regex === null || regex.length !== 7) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const filePath = regex[2];
|
|
8
|
+
const line = +regex[5];
|
|
9
|
+
const column = +regex[6];
|
|
10
|
+
return {
|
|
11
|
+
filePath,
|
|
12
|
+
line,
|
|
13
|
+
column
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=get-error-location-from-file-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-error-location-from-file-path.js","names":["sourceFileWithMapPointerRegex","getErrorLocationFrom","sourceFile","regex","exec","length","filePath","line","column"],"sources":["../../../src/source-maps/get-error-location-from-file-path.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,6BAA6B,QAAQ,+BAA+B;AAQ7E,OAAO,MAAMC,oBAAoB,GAC/BC,UAAkB,IACW;EAC7B,MAAMC,KAAK,GAAGH,6BAA6B,CAACI,IAAI,CAACF,UAAU,CAAC;EAC5D,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,OAAO;IAAEG,QAAQ;IAAEC,IAAI;IAAEC;EAAM,CAAE;AACnC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { getErrorLocationFrom } from './get-error-location-from-file-path.js';
|
|
3
|
+
import { getSourceCode } from './get-source-code.js';
|
|
4
|
+
import { getSourcesFromMapFile } from './get-sources-from-map-file.js';
|
|
5
|
+
export const getErrorRelatedSources = sourceFile => Effect.gen(function* () {
|
|
6
|
+
const location = getErrorLocationFrom(sourceFile);
|
|
7
|
+
if (location === undefined) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const {
|
|
11
|
+
filePath,
|
|
12
|
+
line,
|
|
13
|
+
column
|
|
14
|
+
} = location;
|
|
15
|
+
const isTypescriptFile = filePath.endsWith('.ts');
|
|
16
|
+
if (isTypescriptFile) {
|
|
17
|
+
const source = yield* getSourceCode(location);
|
|
18
|
+
return {
|
|
19
|
+
runPath: `${filePath}:${line}:${column}`,
|
|
20
|
+
sourcesPath: undefined,
|
|
21
|
+
source
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return yield* getSourcesFromMapFile(location);
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=get-error-related-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-error-related-sources.js","names":["Effect","getErrorLocationFrom","getSourceCode","getSourcesFromMapFile","getErrorRelatedSources","sourceFile","gen","location","undefined","filePath","line","column","isTypescriptFile","endsWith","source","runPath","sourcesPath"],"sources":["../../../src/source-maps/get-error-related-sources.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAI/B,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,aAAa,QAAQ,sBAAsB;AACpD,SAEEC,qBAAqB,QAChB,gCAAgC;AAEvC,OAAO,MAAMC,sBAAsB,GACjCC,UAAkB,IAElBL,MAAM,CAACM,GAAG,CAAC,aAAS;EAClB,MAAMC,QAAQ,GAAGN,oBAAoB,CAACI,UAAU,CAAC;EACjD,IAAIE,QAAQ,KAAKC,SAAS,EAAE;IAC1B;EACF;EAEA,MAAM;IAAEC,QAAQ;IAAEC,IAAI;IAAEC;EAAM,CAAE,GAAGJ,QAAQ;EAE3C,MAAMK,gBAAgB,GAAGH,QAAQ,CAACI,QAAQ,CAAC,KAAK,CAAC;EACjD,IAAID,gBAAgB,EAAE;IACpB,MAAME,MAAM,GAAG,OAAOZ,aAAa,CAACK,QAAQ,CAAC;IAE7C,OAAO;MACLQ,OAAO,EAAE,GAAGN,QAAQ,IAAIC,IAAI,IAAIC,MAAM,EAAE;MACxCK,WAAW,EAAER,SAAS;MACtBM;KACD;EACH;EAEA,OAAO,OAAOX,qBAAqB,CAACI,QAAQ,CAAC;AAC/C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { readFileEffect } from '../logic/effects/fs/fs-extra.effects.js';
|
|
3
|
+
const numberOflinesToExtract = 7;
|
|
4
|
+
export const getSourceCode = ({
|
|
5
|
+
filePath,
|
|
6
|
+
line,
|
|
7
|
+
column
|
|
8
|
+
}, isFromJs = false) => Effect.gen(function* () {
|
|
9
|
+
const start = line >= 4 ? line - 4 : 0;
|
|
10
|
+
const sourceCode = yield* readFileEffect(filePath);
|
|
11
|
+
return sourceCode.split('\n').splice(start, numberOflinesToExtract).map((currentLine, index) => {
|
|
12
|
+
const currentLineNumber = index + start + 1;
|
|
13
|
+
const actualColumn = isFromJs ? column + 1 : column;
|
|
14
|
+
return {
|
|
15
|
+
line: currentLineNumber,
|
|
16
|
+
code: currentLine,
|
|
17
|
+
column: currentLineNumber === line ? actualColumn : undefined
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=get-source-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-source-code.js","names":["Effect","readFileEffect","numberOflinesToExtract","getSourceCode","filePath","line","column","isFromJs","gen","start","sourceCode","split","splice","map","currentLine","index","currentLineNumber","actualColumn","code","undefined"],"sources":["../../../src/source-maps/get-source-code.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,cAAc,QAAQ,yCAAyC;AAUxE,MAAMC,sBAAsB,GAAG,CAAC;AAEhC,OAAO,MAAMC,aAAa,GAAGA,CAC3B;EAAEC,QAAQ;EAAEC,IAAI;EAAEC;AAAM,CAAiB,EACzCC,QAAQ,GAAG,KAAK,KAEhBP,MAAM,CAACQ,GAAG,CAAC,aAAS;EAClB,MAAMC,KAAK,GAAGJ,IAAI,IAAI,CAAC,GAAGA,IAAI,GAAG,CAAC,GAAG,CAAC;EAEtC,MAAMK,UAAU,GAAG,OAAOT,cAAc,CAACG,QAAQ,CAAC;EAElD,OAAOM,UAAU,CACdC,KAAK,CAAC,IAAI,CAAC,CACXC,MAAM,CAACH,KAAK,EAAEP,sBAAsB,CAAC,CACrCW,GAAG,CAAC,CAACC,WAAW,EAAEC,KAAK,KAAI;IAC1B,MAAMC,iBAAiB,GAAGD,KAAK,GAAGN,KAAK,GAAG,CAAC;IAE3C,MAAMQ,YAAY,GAAGV,QAAQ,GAAGD,MAAM,GAAG,CAAC,GAAGA,MAAM;IAEnD,OAAO;MACLD,IAAI,EAAEW,iBAAiB;MACvBE,IAAI,EAAEJ,WAAW;MACjBR,MAAM,EAAEU,iBAAiB,KAAKX,IAAI,GAAGY,YAAY,GAAGE;KACrD;EACH,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { Effect } from 'effect';
|
|
4
|
+
import { SourceMapConsumer } from 'source-map-js';
|
|
5
|
+
import { existsEffect, readJsonEffect } from '../logic/effects/fs/fs-extra.effects.js';
|
|
6
|
+
import { getSourceCode } from './get-source-code.js';
|
|
7
|
+
export const getSourcesFromMapFile = location => Effect.gen(function* () {
|
|
8
|
+
const fileExists = yield* existsEffect(`${location.filePath}.map`);
|
|
9
|
+
if (!fileExists) {
|
|
10
|
+
const message = chalk.yellow(`${location.filePath}.map does not exist: unable to retrieve spans sourcemaps.`);
|
|
11
|
+
console.warn(`${chalk.blueBright.underline('effect-errors')}: ${message}`);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const data = yield* readJsonEffect(`${location.filePath}.map`);
|
|
15
|
+
if (data.version === undefined || data.sources === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const consumer = new SourceMapConsumer(data);
|
|
19
|
+
const sources = consumer.originalPositionFor({
|
|
20
|
+
column: location.column,
|
|
21
|
+
line: location.line
|
|
22
|
+
});
|
|
23
|
+
if (sources.source === null || sources.line === null || sources.column === null) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const absolutePath = path.resolve(location.filePath.substring(0, location.filePath.lastIndexOf('/')), sources.source);
|
|
27
|
+
const source = yield* getSourceCode({
|
|
28
|
+
filePath: absolutePath,
|
|
29
|
+
line: sources.line,
|
|
30
|
+
column: sources.column
|
|
31
|
+
}, true);
|
|
32
|
+
return {
|
|
33
|
+
runPath: `${location.filePath}:${location.line}:${location.column}`,
|
|
34
|
+
sourcesPath: `${absolutePath}:${sources.line}:${sources.column + 1}`,
|
|
35
|
+
source
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=get-sources-from-map-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-sources-from-map-file.js","names":["path","chalk","Effect","SourceMapConsumer","existsEffect","readJsonEffect","getSourceCode","getSourcesFromMapFile","location","gen","fileExists","filePath","message","yellow","console","warn","blueBright","underline","data","version","undefined","sources","consumer","originalPositionFor","column","line","source","absolutePath","resolve","substring","lastIndexOf","runPath","sourcesPath"],"sources":["../../../src/source-maps/get-sources-from-map-file.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,QAAQ;AAC/B,SAA4BC,iBAAiB,QAAQ,eAAe;AAGpE,SACEC,YAAY,EACZC,cAAc,QACT,yCAAyC;AAGhD,SAASC,aAAa,QAAyB,sBAAsB;AAQrE,OAAO,MAAMC,qBAAqB,GAChCC,QAAuB,IAEvBN,MAAM,CAACO,GAAG,CAAC,aAAS;EAClB,MAAMC,UAAU,GAAG,OAAON,YAAY,CAAC,GAAGI,QAAQ,CAACG,QAAQ,MAAM,CAAC;EAClE,IAAI,CAACD,UAAU,EAAE;IACf,MAAME,OAAO,GAAGX,KAAK,CAACY,MAAM,CAC1B,GAAGL,QAAQ,CAACG,QAAQ,2DAA2D,CAChF;IACDG,OAAO,CAACC,IAAI,CACV,GAAGd,KAAK,CAACe,UAAU,CAACC,SAAS,CAAC,eAAe,CAAC,KAAKL,OAAO,EAAE,CAC7D;IACD;EACF;EAEA,MAAMM,IAAI,GAAG,OAAOb,cAAc,CAChC,GAAGG,QAAQ,CAACG,QAAQ,MAAM,CAC3B;EACD,IAAIO,IAAI,CAACC,OAAO,KAAKC,SAAS,IAAIF,IAAI,CAACG,OAAO,KAAKD,SAAS,EAAE;IAC5D;EACF;EAEA,MAAME,QAAQ,GAAG,IAAInB,iBAAiB,CAACe,IAAI,CAAC;EAC5C,MAAMG,OAAO,GAAGC,QAAQ,CAACC,mBAAmB,CAAC;IAC3CC,MAAM,EAAEhB,QAAQ,CAACgB,MAAM;IACvBC,IAAI,EAAEjB,QAAQ,CAACiB;GAChB,CAAC;EACF,IACEJ,OAAO,CAACK,MAAM,KAAK,IAAI,IACvBL,OAAO,CAACI,IAAI,KAAK,IAAI,IACrBJ,OAAO,CAACG,MAAM,KAAK,IAAI,EACvB;IACA;EACF;EAEA,MAAMG,YAAY,GAAG3B,IAAI,CAAC4B,OAAO,CAC/BpB,QAAQ,CAACG,QAAQ,CAACkB,SAAS,CAAC,CAAC,EAAErB,QAAQ,CAACG,QAAQ,CAACmB,WAAW,CAAC,GAAG,CAAC,CAAC,EAClET,OAAO,CAACK,MAAM,CACf;EACD,MAAMA,MAAM,GAAG,OAAOpB,aAAa,CACjC;IACEK,QAAQ,EAAEgB,YAAY;IACtBF,IAAI,EAAEJ,OAAO,CAACI,IAAI;IAClBD,MAAM,EAAEH,OAAO,CAACG;GACjB,EACD,IAAI,CACL;EAED,OAAO;IACLO,OAAO,EAAE,GAAGvB,QAAQ,CAACG,QAAQ,IAAIH,QAAQ,CAACiB,IAAI,IAAIjB,QAAQ,CAACgB,MAAM,EAAE;IACnEQ,WAAW,EAAE,GAAGL,YAAY,IAAIN,OAAO,CAACI,IAAI,IAAIJ,OAAO,CAACG,MAAM,GAAG,CAAC,EAAE;IACpEE;GACD;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
import { stackAtRegex } from '../logic/stack/stack-regex.js';
|
|
3
|
+
import { getErrorRelatedSources } from './get-error-related-sources.js';
|
|
4
|
+
export const maybeMapSourcemaps = stacktrace => Effect.forEach(stacktrace, stackLine => Effect.gen(function* () {
|
|
5
|
+
const chunks = stackLine.split(' ');
|
|
6
|
+
const path = chunks.length === 2 ? chunks[1] : chunks[chunks.length - 1].slice(1, -1);
|
|
7
|
+
const details = yield* getErrorRelatedSources(path);
|
|
8
|
+
if (details === undefined) {
|
|
8
9
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
runPath: stackLine.replaceAll(stackAtRegex, 'at '),
|
|
11
|
+
source: undefined,
|
|
12
|
+
sourcesPath: undefined
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
15
|
return {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
runPath: details.runPath,
|
|
17
|
+
sourcesPath: details.sourcesPath,
|
|
18
|
+
source: details.source
|
|
16
19
|
};
|
|
17
20
|
}));
|
|
18
21
|
//# sourceMappingURL=maybe-map-sourcemaps.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe-map-sourcemaps.js","names":["
|
|
1
|
+
{"version":3,"file":"maybe-map-sourcemaps.js","names":["Effect","stackAtRegex","getErrorRelatedSources","maybeMapSourcemaps","stacktrace","forEach","stackLine","gen","chunks","split","path","length","slice","details","undefined","runPath","replaceAll","source","sourcesPath"],"sources":["../../../src/source-maps/maybe-map-sourcemaps.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,QAAQ;AAG/B,SAASC,YAAY,QAAQ,+BAA+B;AAE5D,SAASC,sBAAsB,QAAQ,gCAAgC;AAGvE,OAAO,MAAMC,kBAAkB,GAC7BC,UAAoB,IAEpBJ,MAAM,CAACK,OAAO,CAACD,UAAU,EAAGE,SAAS,IACnCN,MAAM,CAACO,GAAG,CAAC,aAAS;EAClB,MAAMC,MAAM,GAAGF,SAAS,CAACG,KAAK,CAAC,GAAG,CAAC;EACnC,MAAMC,IAAI,GACRF,MAAM,CAACG,MAAM,KAAK,CAAC,GACfH,MAAM,CAAC,CAAC,CAAC,GACTA,MAAM,CAACA,MAAM,CAACG,MAAM,GAAG,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAE5C,MAAMC,OAAO,GAAG,OAAOX,sBAAsB,CAACQ,IAAI,CAAC;EACnD,IAAIG,OAAO,KAAKC,SAAS,EAAE;IACzB,OAAO;MACLC,OAAO,EAAET,SAAS,CAACU,UAAU,CAACf,YAAY,EAAE,KAAK,CAAC;MAClDgB,MAAM,EAAEH,SAAS;MACjBI,WAAW,EAAEJ;KACd;EACH;EAEA,OAAO;IACLC,OAAO,EAAEF,OAAO,CAACE,OAAO;IACxBG,WAAW,EAAEL,OAAO,CAACK,WAAW;IAChCD,MAAM,EAAEJ,OAAO,CAACI;GACjB;AACH,CAAC,CAAC,CACH","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Effect, Option } from 'effect';
|
|
2
|
+
import { splitSpansAttributesByTypes } from '../logic/spans/split-spans-attributes-by-type.js';
|
|
3
|
+
import { stackAtRegex } from '../logic/stack/stack-regex.js';
|
|
4
|
+
import { stripCwdPath } from '../logic/strip-cwd-path.js';
|
|
5
|
+
import { maybeMapSourcemaps } from './maybe-map-sourcemaps.js';
|
|
6
|
+
export const transformRawError = ({
|
|
7
|
+
reverseSpans,
|
|
8
|
+
stripCwd
|
|
9
|
+
}) => ({
|
|
10
|
+
message,
|
|
11
|
+
stack: maybeStack,
|
|
12
|
+
span,
|
|
13
|
+
errorType,
|
|
14
|
+
isPlainString
|
|
15
|
+
}) => Effect.gen(function* () {
|
|
16
|
+
const sources = [];
|
|
17
|
+
const spans = [];
|
|
18
|
+
if (span !== undefined) {
|
|
19
|
+
let current = span;
|
|
20
|
+
while (current !== undefined && current._tag === 'Span') {
|
|
21
|
+
const {
|
|
22
|
+
name,
|
|
23
|
+
attributes: allAttributes,
|
|
24
|
+
status
|
|
25
|
+
} = current;
|
|
26
|
+
const {
|
|
27
|
+
attributes,
|
|
28
|
+
stacktrace
|
|
29
|
+
} = splitSpansAttributesByTypes(allAttributes);
|
|
30
|
+
const errorSources = yield* maybeMapSourcemaps(stacktrace);
|
|
31
|
+
sources.push(...errorSources);
|
|
32
|
+
spans.push({
|
|
33
|
+
name,
|
|
34
|
+
attributes,
|
|
35
|
+
status
|
|
36
|
+
});
|
|
37
|
+
current = Option.getOrUndefined(current.parent);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let stack;
|
|
41
|
+
if (maybeStack !== undefined) {
|
|
42
|
+
stack = stripCwd === true ? stripCwdPath(maybeStack) : maybeStack;
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
errorType,
|
|
46
|
+
message,
|
|
47
|
+
stack: stack?.replaceAll(stackAtRegex, 'at ').split('\r\n'),
|
|
48
|
+
sources: sources.length > 0 ? sources : undefined,
|
|
49
|
+
spans: reverseSpans === true ? spans.toReversed() : spans,
|
|
50
|
+
isPlainString
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=transform-raw-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-raw-error.js","names":["Effect","Option","splitSpansAttributesByTypes","stackAtRegex","stripCwdPath","maybeMapSourcemaps","transformRawError","reverseSpans","stripCwd","message","stack","maybeStack","span","errorType","isPlainString","gen","sources","spans","undefined","current","_tag","name","attributes","allAttributes","status","stacktrace","errorSources","push","getOrUndefined","parent","replaceAll","split","length","toReversed"],"sources":["../../../src/source-maps/transform-raw-error.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,QAAQ;AAIvC,SAASC,2BAA2B,QAAQ,kDAAkD;AAC9F,SAASC,YAAY,QAAQ,+BAA+B;AAC5D,SAASC,YAAY,QAAQ,4BAA4B;AAIzD,SAASC,kBAAkB,QAAQ,2BAA2B;AAE9D,OAAO,MAAMC,iBAAiB,GAC5BA,CAAC;EAAEC,YAAY;EAAEC;AAAQ,CAAwB,KACjD,CAAC;EACCC,OAAO;EACPC,KAAK,EAAEC,UAAU;EACjBC,IAAI;EACJC,SAAS;EACTC;AAAa,CACD,KACZd,MAAM,CAACe,GAAG,CAAC,aAAS;EAClB,MAAMC,OAAO,GAA0B,EAAE;EACzC,MAAMC,KAAK,GAAG,EAAE;EAEhB,IAAIL,IAAI,KAAKM,SAAS,EAAE;IACtB,IAAIC,OAAO,GAA+BP,IAAI;IAE9C,OAAOO,OAAO,KAAKD,SAAS,IAAIC,OAAO,CAACC,IAAI,KAAK,MAAM,EAAE;MACvD,MAAM;QAAEC,IAAI;QAAEC,UAAU,EAAEC,aAAa;QAAEC;MAAM,CAAE,GAAGL,OAAO;MAE3D,MAAM;QAAEG,UAAU;QAAEG;MAAU,CAAE,GAC9BvB,2BAA2B,CAACqB,aAAa,CAAC;MAE5C,MAAMG,YAAY,GAAG,OAAOrB,kBAAkB,CAACoB,UAAU,CAAC;MAE1DT,OAAO,CAACW,IAAI,CAAC,GAAGD,YAAY,CAAC;MAC7BT,KAAK,CAACU,IAAI,CAAC;QACTN,IAAI;QACJC,UAAU;QACVE;OACD,CAAC;MACFL,OAAO,GAAGlB,MAAM,CAAC2B,cAAc,CAACT,OAAO,CAACU,MAAM,CAAC;IACjD;EACF;EAEA,IAAInB,KAAK;EACT,IAAIC,UAAU,KAAKO,SAAS,EAAE;IAC5BR,KAAK,GAAGF,QAAQ,KAAK,IAAI,GAAGJ,YAAY,CAACO,UAAU,CAAC,GAAGA,UAAU;EACnE;EAEA,OAAO;IACLE,SAAS;IACTJ,OAAO;IACPC,KAAK,EAAEA,KAAK,EAAEoB,UAAU,CAAC3B,YAAY,EAAE,KAAK,CAAC,CAAC4B,KAAK,CAAC,MAAM,CAAC;IAC3Df,OAAO,EAAEA,OAAO,CAACgB,MAAM,GAAG,CAAC,GAAGhB,OAAO,GAAGE,SAAS;IACjDD,KAAK,EAAEV,YAAY,KAAK,IAAI,GAAGU,KAAK,CAACgB,UAAU,EAAE,GAAGhB,KAAK;IACzDH;GACD;AACH,CAAC,CAAC","ignoreList":[]}
|