(error: unknown)
| 101 | * Removes sensitive information and formats for user consumption |
| 102 | */ |
| 103 | export function sanitizeErrorMessage(error: unknown): string { |
| 104 | if (error instanceof Error) { |
| 105 | return error.message |
| 106 | } |
| 107 | if (typeof error === 'string') { |
| 108 | return error |
| 109 | } |
| 110 | if (error && typeof error === 'object' && 'message' in error) { |
| 111 | const message = (error as { message: unknown }).message |
| 112 | if (typeof message === 'string') { |
| 113 | return message |
| 114 | } |
| 115 | } |
| 116 | return String(error) |
| 117 | } |
no outgoing calls
no test coverage detected