MCPcopy Create free account
hub / github.com/dailydotdev/apps / getBetterAuthErrorMessage

Function getBetterAuthErrorMessage

packages/shared/src/lib/betterAuth.ts:25–54  ·  view source on GitHub ↗
(
  error: unknown,
  fallbackError = 'Request failed',
)

Source from the content-addressed store, hash-verified

23}>;
24
25export const getBetterAuthErrorMessage = (
26 error: unknown,
27 fallbackError = 'Request failed',
28): string => {
29 if (typeof error === 'string' && error) {
30 return error;
31 }
32
33 if (error && typeof error === 'object') {
34 if ('message' in error && typeof error.message === 'string') {
35 return error.message;
36 }
37
38 if ('error' in error && typeof error.error === 'string') {
39 return error.error;
40 }
41
42 if ('code' in error && typeof error.code === 'string') {
43 return error.code;
44 }
45
46 try {
47 return JSON.stringify(error);
48 } catch {
49 return fallbackError;
50 }
51 }
52
53 return fallbackError;
54};
55
56const betterAuthPost = async <T = Record<string, unknown>>(
57 path: string,

Callers 5

handleLoginMessageFunction · 0.90
useLoginFunction · 0.90
onSocialRegistrationFunction · 0.90
betterAuthPostFunction · 0.85
betterAuthSetPasswordFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected