(code: unknown, fallbackMessage: string = FALLBACK_MESSAGE)
| 89 | * has no corresponding message. |
| 90 | */ |
| 91 | export function getMessageFromCode(code: unknown, fallbackMessage: string = FALLBACK_MESSAGE): string { |
| 92 | if (isValidCode(code)) { |
| 93 | const codeString = code.toString(); |
| 94 | |
| 95 | if (Object.hasOwn(errorValues, codeString)) { |
| 96 | return errorValues[codeString as ErrorValueKey].message; |
| 97 | } |
| 98 | |
| 99 | if (isJsonRpcServerError(code)) { |
| 100 | return JSON_RPC_SERVER_ERROR_MESSAGE; |
| 101 | } |
| 102 | } |
| 103 | return fallbackMessage; |
| 104 | } |
| 105 | |
| 106 | const FALLBACK_ERROR: JRPCError = { |
| 107 | code: FALLBACK_ERROR_CODE, |
no test coverage detected