MCPcopy Create free account
hub / github.com/sindresorhus/execa / getFinalError

Function getFinalError

lib/return/final-error.js:3–7  ·  view source on GitHub ↗
(originalError, message, isSync)

Source from the content-addressed store, hash-verified

1// When the subprocess fails, this is the error instance being returned.
2// If another error instance is being thrown, it is kept as `error.cause`.
3export const getFinalError = (originalError, message, isSync) => {
4 const ErrorClass = isSync ? ExecaSyncError : ExecaError;
5 const options = originalError instanceof DiscardedError ? {} : {cause: originalError};
6 return new ErrorClass(message, options);
7};
8
9// Indicates that the error is used only to interrupt control flow, but not in the return value
10export class DiscardedError extends Error {}

Callers 1

makeErrorFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected