(error: unknown)
| 203 | * @returns A JSON-serializable object containing as much information about the original error as possible. |
| 204 | */ |
| 205 | export function serializeCause(error: unknown): Json { |
| 206 | if (Array.isArray(error)) { |
| 207 | return error.map((entry) => { |
| 208 | if (isValidJson(entry)) { |
| 209 | return entry; |
| 210 | } else if (isObject(entry)) { |
| 211 | return serializeObject(entry); |
| 212 | } |
| 213 | return null; |
| 214 | }); |
| 215 | } else if (isObject(error)) { |
| 216 | return serializeObject(error); |
| 217 | } |
| 218 | |
| 219 | if (isValidJson(error)) { |
| 220 | return error; |
| 221 | } |
| 222 | |
| 223 | return null; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Extracts all JSON-serializable properties from an object. |
no test coverage detected
searching dependent graphs…