UNPKG

msw

Version:

Seamless REST/GraphQL API mocking library for browser and Node.js.

15 lines (14 loc) 472 B
/** * Determines if the given value is shaped like a Node.js exception. * Node.js exceptions have additional information, like * the `code` and `errno` properties. * * In some environments, particularly jsdom/jest these may not * instances of `Error` or its subclasses, despite being similar * to them. */ export function isNodeExceptionLike( error: unknown, ): error is NodeJS.ErrnoException { return !!error && typeof error === 'object' && 'code' in error }