Skip to content
Myr

Add `error.originalMessage` property (#373)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by Sindre Sorhus · parent 492dff4 · Browse files · 5 files+23 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+23 added−0 removed

  • tests:+5 added−0 removed
  • other:+18 added−0 removed

5 files+23 added−0 removed

modified:lib/error.js+1 added
modified:test/error.js+5 added
161 unmodified lines
162errorMessage.title = (message, expected) => `error.message matches: ${expected}`;163164test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');165test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');166167test('Original error message is kept', async t => {168 const {originalMessage} = await t.throwsAsync(execa('wrong command'));169 t.is(originalMessage, 'spawn wrong command ENOENT');170});
modified:index.d.ts+7 added
300 unmodified lines
301 /**302 The error message.303 */304 message: string;305306 /**307 Original error message. This is `undefined` unless the child process exited due to an `error` event or a timeout.308309 The `message` property contains both the `originalMessage` and some additional information added by Execa.310 */311 originalMessage?: string;312 }313314 interface ExecaError<StdoutErrorType = string>315 extends ExecaSyncError<StdoutErrorType> {
190 unmodified lines
modified:index.test-d.ts+2 added
38 unmodified lines
39 expectType<boolean>(execaError.timedOut);40 expectType<boolean>(execaError.isCanceled);41 expectType<boolean>(execaError.killed);42 expectType<string | undefined>(execaError.signal);43 expectType<string | undefined>(execaError.originalMessage);44}4546try {47 const unicornsResult = execa.sync('unicorns');
21 unmodified lines
69 expectType<boolean>(execaError.timedOut);70 expectError(execaError.isCanceled);71 expectType<boolean>(execaError.killed);72 expectType<string | undefined>(execaError.signal);73 expectType<string | undefined>(execaError.originalMessage);74}7576execa('unicorns', {cleanup: false});77execa('unicorns', {preferLocal: false});
109 unmodified lines
modified:readme.md+8 added
275 unmodified lines
276Type: `string | undefined`277278The signal that was used to terminate the process.279280#### originalMessage281282Type: `string | undefined`283284Original error message. This is `undefined` unless the child process exited due to an `error` event or a timeout.285286The `message` property contains both the `originalMessage` and some additional information added by Execa.287288### options289290Type: `object`291
268 unmodified lines