refactor(frontend): extract extractErrorCode() helper to eliminate repeated type assertions #649
@@ -23,3 +23,12 @@ export function createApiClient(fetch: typeof globalThis.fetch) {
|
||||
fetch
|
||||
});
|
||||
}
|
||||
|
||||
export interface ApiError {
|
||||
code?: string;
|
||||
message?: string;
|
||||
}
|
||||
|
||||
export function extractErrorCode(error: unknown): string | undefined {
|
||||
return (error as ApiError | undefined)?.code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user