1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = isError;
|
7 | var _prettyFormat = require('pretty-format');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function isError(
|
16 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
17 | potentialError
|
18 | ) {
|
19 |
|
20 | const isError =
|
21 | potentialError !== null &&
|
22 | typeof potentialError === 'object' &&
|
23 | typeof potentialError.message === 'string' &&
|
24 | typeof potentialError.name === 'string';
|
25 | const message = isError
|
26 | ? null
|
27 | : `Failed: ${(0, _prettyFormat.format)(potentialError, {
|
28 | maxDepth: 3
|
29 | })}`;
|
30 | return {
|
31 | isError,
|
32 | message
|
33 | };
|
34 | }
|