Skip to content

Commit

Permalink
refactor: change return error type from CantClaim to CantUnclaim in `…
Browse files Browse the repository at this point in the history
…apiUnclaimLocker()`
  • Loading branch information
EATSTEAK committed Sep 8, 2022
1 parent e7b9952 commit f936f7d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/client/src/lib/api/locker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BadRequestErrorSchema,
BlockedErrorSchema,
CantClaimErrorSchema,
CantUnclaimErrorSchema,
createErrorResponse,
createSuccessResponse,
ForbiddenErrorSchema,
Expand Down Expand Up @@ -111,7 +112,7 @@ export async function apiClaimLocker(

export async function apiUnclaimLocker(): Promise<
| SuccessResponse<UnclaimLockerResponse>
| ErrorResponse<BlockedError | ForbiddenError | CantClaimError>
| ErrorResponse<BlockedError | ForbiddenError | CantUnclaimError>
> {
const response = await apiRequest<UnclaimLockerResponse>('/locker/unclaim', true, {
method: 'POST'
Expand All @@ -128,9 +129,9 @@ export async function apiUnclaimLocker(): Promise<
if (forbidden.success) {
return forbidden.data as ErrorResponse<ForbiddenError>;
}
const cantClaim = createErrorResponse(CantClaimErrorSchema).safeParse(response);
if (cantClaim.success) {
return cantClaim.data as ErrorResponse<CantClaimError>;
const cantUnclaim = createErrorResponse(CantUnclaimErrorSchema).safeParse(response);
if (cantUnclaim.success) {
return cantUnclaim.data as ErrorResponse<CantUnclaimError>;
}
const other = createErrorResponse().parse(response);
throw other.error;
Expand Down

0 comments on commit f936f7d

Please sign in to comment.