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