Skip to content

Commit

Permalink
Improve plugin.launch() error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 6, 2022
1 parent 6a34b42 commit a1b00a9
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/combination/tasks/load.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserError, PluginError } from '../../error/main.js'
import { PluginError } from '../../error/main.js'
import { wrapError } from '../../error/wrap.js'
import { computeRunnerVersions } from '../../top/system/versions/compute.js'

Expand All @@ -24,17 +24,13 @@ export const loadRunner = async function (
return { id, spawn, spawnOptions, versions: versionsA, config }
}

// Fire `runner.launch()`
// Fire `runner.launch()`.
// Errors are always considered plugin errors.
// User errors should be captured in `plugin.config` instead.
const launchRunner = async function ({ id, config, launch }) {
try {
return await launch(config)
} catch (error) {
throw getLaunchError(error, id)
throw wrapError(error, `In runner '${id}':`, PluginError)
}
}

const getLaunchError = function (error, id) {
return error instanceof UserError
? wrapError(error, `In runner '${id}':`, UserError)
: wrapError(error, `In runner '${id}', internal error:`, PluginError)
}

0 comments on commit a1b00a9

Please sign in to comment.