Skip to content

Commit

Permalink
More error wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jan 23, 2022
1 parent eab1a1e commit 263f137
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/runners/node/handler/start/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UserError } from '../../../../error/main.js'
import { wrapError } from '../../../../error/wrap.js'
import { importJsNamed } from '../../../../utils/import.js'

import { addDefaults } from './default.js'
Expand Down Expand Up @@ -27,8 +28,10 @@ const importFile = async function (taskPath) {
try {
return await importJsNamed(taskPath)
} catch (error) {
throw new UserError(
`Could not import the tasks file ${taskPath}\n${error.stack}`,
throw wrapError(
error,
`Could not import the tasks file ${taskPath}\n`,
UserError,
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/runners/node/launch/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const HANDLER_MAIN_PATH = fileURLToPath(
)

// Retrieve Node commands. By default it uses the current Node.js.
// But `runnerNode.version` can be used to spawn a different Node.js version.
// But `runnerConfig.node.version` can be used to spawn a different Node.js
// version.
export const launch = async function (runnerConfig) {
validateConfig(runnerConfig)

Expand Down
2 changes: 1 addition & 1 deletion src/runners/node/launch/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const getAllowedVersions = async function () {
const validateVersion = function ({ versionRange, version }, allowedVersions) {
if (!semver.satisfies(version, allowedVersions)) {
throw new UserError(
`In the configuration property "runnerNode.version"
`Configuration property "runnerConfig.node.version":
Version ${versionRange} is invalid: it must be ${allowedVersions}`,
)
}
Expand Down

0 comments on commit 263f137

Please sign in to comment.