feat(#417): update auth-client.ts error messages to PDA-friendly
Uses parseAuthError from auth-errors module for consistent PDA-friendly error messages in signInWithCredentials. Refs #417
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
import { createAuthClient } from "better-auth/react";
|
||||
import { genericOAuthClient } from "better-auth/client/plugins";
|
||||
import { API_BASE_URL } from "./config";
|
||||
import { parseAuthError } from "./auth/auth-errors";
|
||||
|
||||
/**
|
||||
* Auth client instance configured for Mosaic Stack.
|
||||
@@ -42,8 +43,9 @@ export async function signInWithCredentials(username: string, password: string):
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = (await response.json().catch(() => ({}))) as { message?: string };
|
||||
throw new Error(error.message ?? "Authentication failed");
|
||||
const errorBody = (await response.json().catch(() => ({}))) as { message?: string };
|
||||
const parsed = parseAuthError(errorBody.message ? new Error(errorBody.message) : response);
|
||||
throw new Error(parsed.message);
|
||||
}
|
||||
|
||||
const data = (await response.json()) as unknown;
|
||||
|
||||
Reference in New Issue
Block a user