diff --git a/packages/core/src/core/command-tree.ts b/packages/core/src/core/command-tree.ts index 5272d20e160..3d54c0f1c6f 100644 --- a/packages/core/src/core/command-tree.ts +++ b/packages/core/src/core/command-tree.ts @@ -417,7 +417,7 @@ const withEvents = ( } } - if (err.code === 127 && partialMatches) { + if (err && err.code === 127 && partialMatches) { // command not found const suggestions = suggestPartialMatches(command, partialMatches, true, err.hide) // true: don't throw an exception return suggestions diff --git a/packages/core/src/core/oops.ts b/packages/core/src/core/oops.ts index 47fee465fdb..d8414d33b07 100644 --- a/packages/core/src/core/oops.ts +++ b/packages/core/src/core/oops.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +/* eslint-disable no-use-before-define */ + interface ErrorWithResultField { error: { response: { @@ -89,6 +91,8 @@ export const oopsMessage = (err: ErrorLike): string => { try { if (typeof err === 'string') { return err + } else if (typeof err === 'undefined') { + return '' } else if (isErrorWithNestedResultField(err)) { return err.error.response.result.error.error // feed creation error. nice } else if (isErrorWithResultField(err)) { diff --git a/packages/core/src/main/headless.ts b/packages/core/src/main/headless.ts index b3cfcf662b0..dbb27e23a51 100644 --- a/packages/core/src/main/headless.ts +++ b/packages/core/src/main/headless.ts @@ -93,6 +93,8 @@ const success = (quit: QuitFunction) => async (out: Entity | Promise) => const failure = (quit: QuitFunction, execOptions?: ExecOptions) => async (err: CodedError) => { if (execOptions && execOptions.rethrowErrors) { throw err + } else if (!err) { + return } const code = err.code || err.statusCode