error-stack2
Advanced tools
Comparing version 1.0.18 to 2.0.1
{ | ||
"name": "error-stack2", | ||
"version": "1.0.18", | ||
"version": "2.0.1", | ||
"description": "Parse and manipulate error.stack", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"pretest": "echo pretest", | ||
"test": "tsdx test", | ||
"test": "jest", | ||
"posttest": "echo posttest", | ||
@@ -91,5 +91,5 @@ "prebuild": "yarn run test", | ||
"@types/jest": "^27.4.0", | ||
"@types/node": "^17.0.13" | ||
"@types/node": "^17.0.14" | ||
}, | ||
"packageManager": "yarn@^1.22.11" | ||
} |
import { ITSPickExtra, ITSRequireAtLeastOne } from 'ts-type/lib/type/record'; | ||
import { lineSplit, R_CRLF } from 'crlf-normalize'; | ||
import { lineSplit, R_CRLF, LF } from 'crlf-normalize'; | ||
import { IEvalTrace, IParsed, IParsedWithoutTrace, ISource, ITrace, IRawLineTrace, ITraceValue } from './types'; | ||
@@ -12,3 +12,2 @@ import { stringSplitWithLimit } from 'string-split-keep2'; | ||
const AT = 'at' as const | ||
const CR = '\n' as const | ||
@@ -19,3 +18,3 @@ // 1. | ||
// TypeError: foo | ||
const REGEX_MATCH_MESSAGE = /^([a-z][a-z0-9_]*)(?: \[(\w+)\])?:(?: ([\s\S]*))?$/i | ||
const REGEX_MATCH_MESSAGE = /^([a-z][a-z0-9_]*)(?:(?: \[(\w+)\])?:(?: ([\s\S]*))?)?$/i | ||
@@ -259,5 +258,5 @@ const REGEX_REMOVE_AT = /^at\s+/ | ||
// A error message might have multiple lines | ||
const index = rawTrace.findIndex(line => line.trimLeft().startsWith(AT) && validTrace(parseTrace(trim(line), true))) | ||
const index = rawTrace.findIndex(line => line.trimLeft().startsWith(AT) && validTrace(parseTrace(trim(line), true))); | ||
rawMessage = [rawMessage, ...rawTrace.splice(0, index)].join(CR) | ||
rawMessage = [rawMessage, ...rawTrace.splice(0, index)].join(LF) | ||
} | ||
@@ -391,3 +390,10 @@ | ||
{ | ||
return `${formatMessagePrefix(parsed)}: ${parsed.message ?? ''}`; | ||
let line = formatMessagePrefix(parsed); | ||
if (typeof parsed.message !== 'undefined') | ||
{ | ||
line += `: ${parsed.message ?? ''}`; | ||
} | ||
return line; | ||
} | ||
@@ -479,6 +485,7 @@ | ||
const tracesLines = (parsed.traces?.map(formatTraceLine) ?? parsed.rawTrace) | ||
.join(CR) | ||
.join(LF) | ||
; | ||
return tracesLines | ||
? messageLines + CR + tracesLines | ||
? messageLines + LF + tracesLines | ||
: messageLines | ||
@@ -485,0 +492,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99636
1263