Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Mask errors from main hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Mar 26, 2019
1 parent 9ede7cb commit 950e741
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/hook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { dirname } from "../safe/path.js"
import dualResolveFilename from "../module/internal/dual-resolve-filename.js"
import esmParseLoad from "../module/esm/parse-load.js"
import getSilent from "../util/get-silent.js"
import isStackTraceMaskable from "../util/is-stack-trace-maskable.js"
import maskStackTrace from "../error/mask-stack-trace.js"
import realProcess from "../real/process.js"
import relaxRange from "../util/relax-range.js"
import toExternalError from "../util/to-external-error.js"

function hook(Mod) {
function managerWrapper(manager, func, args) {
Expand All @@ -34,7 +37,19 @@ function hook(Mod) {
Package.set(dirPath, defaultPkg.clone())
}

esmParseLoad(mainPath, null, true)
try {
esmParseLoad(mainPath, null, true)
} catch (e) {
if (! defaultPkg.options.debug &&
isStackTraceMaskable(e)) {
maskStackTrace(e, { filename })
} else {
toExternalError(e)
}

throw e
}

tickCallback()
}

Expand Down

0 comments on commit 950e741

Please sign in to comment.