(u: unknown)
| 947 | * @internal |
| 948 | */ |
| 949 | export const prettyErrorMessage = (u: unknown): string => { |
| 950 | // 1) |
| 951 | if (typeof u === "string") { |
| 952 | return u |
| 953 | } |
| 954 | // 2) |
| 955 | if (typeof u === "object" && u !== null && u instanceof Error) { |
| 956 | return u.message |
| 957 | } |
| 958 | // 3) |
| 959 | try { |
| 960 | if ( |
| 961 | hasProperty(u, "toString") && |
| 962 | isFunction(u["toString"]) && |
| 963 | u["toString"] !== Object.prototype.toString && |
| 964 | u["toString"] !== globalThis.Array.prototype.toString |
| 965 | ) { |
| 966 | return u["toString"]() |
| 967 | } |
| 968 | } catch { |
| 969 | // something's off, rollback to json |
| 970 | } |
| 971 | // 4) |
| 972 | return stringifyCircular(u) |
| 973 | } |
| 974 | |
| 975 | const locationRegex = /\((.*)\)/g |
| 976 |
no test coverage detected