MCPcopy Create free account
hub / github.com/Web3Auth/Auth / getMessageFromCode

Function getMessageFromCode

src/jrpc/errors/utils.ts:91–104  ·  view source on GitHub ↗
(code: unknown, fallbackMessage: string = FALLBACK_MESSAGE)

Source from the content-addressed store, hash-verified

89 * has no corresponding message.
90 */
91export 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
106const FALLBACK_ERROR: JRPCError = {
107 code: FALLBACK_ERROR_CODE,

Callers 8

jrpcErrors.test.tsFile · 0.90
jrpcUtils.test.tsFile · 0.90
constructFallbackErrorFunction · 0.90
providerFromEngineFunction · 0.90
deserializeErrorFunction · 0.90
getJsonRpcErrorFunction · 0.90
getEthProviderErrorFunction · 0.90
utils.tsFile · 0.85

Calls 3

isValidCodeFunction · 0.85
isJsonRpcServerErrorFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected