feat: enhance API error handling and response structure; introduce ApiException for V2 error codes
This commit is contained in:
@@ -55,20 +55,6 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
|
||||
final Map<String, dynamic> body =
|
||||
response.data as Map<String, dynamic>;
|
||||
|
||||
// Check for V2 error responses.
|
||||
if (response.code != '200' && response.code != '201') {
|
||||
final String errorCode = body['code']?.toString() ?? response.code;
|
||||
if (errorCode == 'INVALID_CREDENTIALS' ||
|
||||
response.message.contains('INVALID_LOGIN_CREDENTIALS')) {
|
||||
throw InvalidCredentialsException(
|
||||
technicalMessage: response.message,
|
||||
);
|
||||
}
|
||||
throw SignInFailedException(
|
||||
technicalMessage: '$errorCode: ${response.message}',
|
||||
);
|
||||
}
|
||||
|
||||
// Step 2: Sign in locally so AuthInterceptor can attach Bearer tokens
|
||||
// to subsequent requests. The V2 API already validated credentials, so
|
||||
// email/password sign-in establishes the local Firebase Auth state.
|
||||
@@ -115,12 +101,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
|
||||
},
|
||||
);
|
||||
|
||||
// Check for V2 error responses.
|
||||
final Map<String, dynamic> body = response.data as Map<String, dynamic>;
|
||||
if (response.code != '201' && response.code != '200') {
|
||||
final String errorCode = body['code']?.toString() ?? response.code;
|
||||
_throwSignUpError(errorCode, response.message);
|
||||
}
|
||||
|
||||
// Step 2: Sign in locally to Firebase Auth so AuthInterceptor works
|
||||
// for subsequent requests. The V2 API already created the Firebase
|
||||
|
||||
Reference in New Issue
Block a user