Skip to content

Commit

Permalink
Merge pull request #73 from TypingMind/refactor-article-reader
Browse files Browse the repository at this point in the history
fix(webpage reader): properly handle errors when the api encounters a fetch error
  • Loading branch information
dat-devuap authored Jan 21, 2025
2 parents 5a4271a + b7ddb20 commit a65aa5e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/routes/webPageReader/webPageReaderRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ export const webPageReaderRouter: Router = (() => {
content,
StatusCodes.OK
);
handleServiceResponse(serviceResponse, res);
return handleServiceResponse(serviceResponse, res);
} catch (error) {
console.error(`Error fetching content ${(error as Error).message}`);
const errorMessage = `Error fetching content $${(error as Error).message}`;
return new ServiceResponse(ResponseStatus.Failed, errorMessage, null, StatusCodes.INTERNAL_SERVER_ERROR);
const errorMessage = `Error fetching content ${(error as Error).message}`;
const serviceResponse = new ServiceResponse(
ResponseStatus.Failed,
errorMessage,
null,
StatusCodes.INTERNAL_SERVER_ERROR
);
return handleServiceResponse(serviceResponse, res);
}
});

Expand Down

0 comments on commit a65aa5e

Please sign in to comment.