Skip to content

Commit

Permalink
πŸ› fix: νƒ€μž…κ°€λ“œ ν•¨μˆ˜ μΆ”κ°€
Browse files Browse the repository at this point in the history
  • Loading branch information
froggy1014 committed Aug 15, 2024
1 parent d3ddc40 commit ce99323
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/apis/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ export class ReviewError extends FiestaError {
}
}

function isFiestaError(error: unknown): error is FiestaError {
return (
typeof error === "object" &&
error !== null &&
"code" in error &&
"message" in error &&
"statusCode" in error
);
}

export function createFiestaError(error: unknown) {
if (
typeof error !== "object" ||
error === null ||
!("code" in error) ||
!("message" in error) ||
!("statusCode" in error)
) {
if (!isFiestaError(error)) {
return new Error(`Unknown Error: ${JSON.stringify(error)}`);
}

const { code, message, statusCode } = error as FiestaError;
const { code, message, statusCode } = error;
const initial = code.charAt(0);

if (initial === "S") {
Expand Down

0 comments on commit ce99323

Please sign in to comment.