MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / getGraphQLErrorMessage

Function getGraphQLErrorMessage

web/dashboard/src/utils/index.ts:103–122  ·  view source on GitHub ↗
(
	error: unknown,
	fallback = 'Something went wrong',
)

Source from the content-addressed store, hash-verified

101 * Prefers the first GraphQL error message, then the error's message, then a fallback.
102 */
103export const getGraphQLErrorMessage = (
104 error: unknown,
105 fallback = 'Something went wrong',
106): string => {
107 if (!error || typeof error !== 'object') return fallback;
108 const err = error as {
109 message?: string;
110 graphQLErrors?: Array<{ message?: string }>;
111 networkError?: { message?: string };
112 };
113 if (Array.isArray(err.graphQLErrors) && err.graphQLErrors.length > 0) {
114 const first = err.graphQLErrors[0];
115 if (first?.message && typeof first.message === 'string') {
116 return first.message;
117 }
118 }
119 if (err.message && typeof err.message === 'string') return err.message;
120 if (err.networkError?.message) return err.networkError.message;
121 return fallback;
122};

Callers 11

updateTemplateFunction · 0.90
saveHandlerFunction · 0.90
deleteHandlerFunction · 0.90
saveDataFunction · 0.90
deleteHandlerFunction · 0.90
deleteHandlerFunction · 0.90
sendInviteHandlerFunction · 0.90
userVerificationHandlerFunction · 0.90
updateAccessHandlerFunction · 0.90
AuthFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected