refactor(errors): classify auth and browser failures
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { AuthApi, authApi } from "@/data/services/api";
|
||||
import { ExceptionHandler } from "@/core/errors";
|
||||
import { ApiError, AuthApi, authApi, ErrorCode } from "@/data/services/api";
|
||||
import {
|
||||
AppleLoginRequest,
|
||||
FacebookLoginRequest,
|
||||
@@ -141,9 +142,10 @@ export class AuthRepository implements IAuthRepository {
|
||||
}
|
||||
return response;
|
||||
}).catch((e) => {
|
||||
const errorResult = ExceptionHandler.handle(e);
|
||||
log.error("[AuthRepository.guestLogin] API call FAILED", {
|
||||
errorName: e?.name,
|
||||
errorMessage: e?.message,
|
||||
errorCode: errorResult.code,
|
||||
errorMessage: errorResult.message,
|
||||
});
|
||||
return Result.err(e);
|
||||
});
|
||||
@@ -227,7 +229,13 @@ export class AuthRepository implements IAuthRepository {
|
||||
async refreshToken(): Promise<Result<RefreshTokenResponse>> {
|
||||
const existing = await this.storage.getRefreshToken();
|
||||
if (!existing.success || !existing.data) {
|
||||
return Result.err(new Error("No refresh token available"));
|
||||
return Result.err(
|
||||
new ApiError(
|
||||
"HTTP_UNAUTHORIZED",
|
||||
"No refresh token available",
|
||||
ErrorCode.httpUnauthorized,
|
||||
),
|
||||
);
|
||||
}
|
||||
const refreshToken = existing.data;
|
||||
return Result.wrap(async () => {
|
||||
|
||||
Reference in New Issue
Block a user