Skip to content

Commit

Permalink
fix: la poste pdf incorrectly cast as 404 (#1265)
Browse files Browse the repository at this point in the history
* fix: la poste pdf incorrectly cast as 404

* Update hooks/fetch/download-pdf.ts

Co-authored-by: Robin Monnier <[email protected]>
Signed-off-by: Xavier Jp <[email protected]>

---------

Signed-off-by: Xavier Jp <[email protected]>
Co-authored-by: Robin Monnier <[email protected]>
  • Loading branch information
XavierJp and rmonnier9 authored Oct 11, 2024
1 parent d80f9d5 commit d2e1c11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hooks/fetch/download-pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { httpGet } from '#utils/network';
import logErrorInSentry from '#utils/sentry';
import { useFetchExternalData } from './use-fetch-data';

const is404 = (msg: string) => msg.indexOf('Siren non existant') !== 0;
const isPdfNotFound = (msg: string) => msg.indexOf('Siren non existant') === 0;

export function usePDFDownloader(pdfLink: string) {
return useFetchExternalData(
Expand All @@ -14,7 +14,7 @@ export function usePDFDownloader(pdfLink: string) {
try {
return await httpGet<Blob>(pdfLink, { responseType: 'blob' });
} catch (e: any) {
if (is404(e?.message)) {
if (isPdfNotFound(e?.message)) {
throw new HttpNotFound('Not found - 404');
}
throw e;
Expand Down

0 comments on commit d2e1c11

Please sign in to comment.