diff --git a/scripts/content.js b/scripts/content.js index d2230c9..ce0998a 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -129,10 +129,8 @@ async function handleHttpError(e) { console.log(msg); await sendNotification(msg); await logOut(); - return null; } else { console.error(e); - return null; } } @@ -211,12 +209,16 @@ async function getAvailableDates(consulateId) { let uri = window.location.pathname + `/days/${consulateId}.json?appointments[expedite]=false` let dates = fetch(uri, { headers: { "x-requested-with": "XMLHttpRequest" }}) .then(d => d.json()) + .catch(async e => { + await handleHttpError(e); + throw e; + }) .then(data => { let dateList = data.map(item => item.date); dateList.sort(); return dateList; }) - .catch(async e => handleHttpError(e)); + .catch(e => null); return dates; } @@ -234,8 +236,12 @@ async function getAvailableTimes(consulateId, date) { let uri = window.location.pathname + `/times/${consulateId}.json?date=${date}&appointments[expedite]=false` let times = await fetch(uri, { headers: { "x-requested-with": "XMLHttpRequest" } }) .then(d => d.json()) + .catch(async e => { + await handleHttpError(e); + throw e; + }) .then(data => data.available_times) - .catch(e => handleHttpError(e)); + .catch(e => null); return times; }