( code: unknown, fallbackMessage: string = FALLBACK_MESSAGE, )
| 60 | * has no corresponding message. |
| 61 | */ |
| 62 | export function getMessageFromCode( |
| 63 | code: unknown, |
| 64 | fallbackMessage: string = FALLBACK_MESSAGE, |
| 65 | ): string { |
| 66 | if (isValidCode(code)) { |
| 67 | const codeString = code.toString(); |
| 68 | |
| 69 | if (hasProperty(errorValues, codeString)) { |
| 70 | return errorValues[codeString as ErrorValueKey].message; |
| 71 | } |
| 72 | |
| 73 | if (isJsonRpcServerError(code)) { |
| 74 | return JSON_RPC_SERVER_ERROR_MESSAGE; |
| 75 | } |
| 76 | } |
| 77 | return fallbackMessage; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Returns whether the given code is valid. |
no test coverage detected
searching dependent graphs…