Skip to content

Commit

Permalink
Merge pull request #370 from Quickchive/fix/catch-axios-4xx-error
Browse files Browse the repository at this point in the history
fix: catch axios 4xx errors
  • Loading branch information
stae1102 authored Jan 12, 2025
2 parents 991792b + 9721de2 commit be77adc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/contents/util/content.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,16 @@ class OGCrawler {

return this.parse(response.data);
} catch (error) {
if (error instanceof AxiosError && error.response?.status === 403) {
throw new ForbiddenException('og 데이터를 가져올 수 없는 링크입니다.');
if (error instanceof AxiosError) {
if (
error?.response?.status === 400 ||
error.response?.status === 403 ||
error.response?.status === 404
) {
throw new ForbiddenException(
'og 데이터를 가져올 수 없는 링크입니다.',
);
}
}

throw new InternalServerErrorException('An unknown error occurred');
Expand Down

0 comments on commit be77adc

Please sign in to comment.