( err: unknown, contextMessage?: string, level: ErrorLevel = ErrorLevelEnum.Error )
| 104 | * ``` |
| 105 | */ |
| 106 | export function reportError( |
| 107 | err: unknown, |
| 108 | contextMessage?: string, |
| 109 | level: ErrorLevel = ErrorLevelEnum.Error |
| 110 | ): void { |
| 111 | const error = toError(err, contextMessage); |
| 112 | |
| 113 | switch (level) { |
| 114 | case ErrorLevelEnum.Error: |
| 115 | log.logError(error); |
| 116 | break; |
| 117 | case ErrorLevelEnum.Warning: |
| 118 | log.logWarning(error); |
| 119 | break; |
| 120 | case ErrorLevelEnum.Log: |
| 121 | log.logMessage(error); |
| 122 | break; |
| 123 | default: |
| 124 | // Ensure exhaustiveness |
| 125 | log.logError(error); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Error boundary - wraps a function and reports any errors it throws |
no test coverage detected