Prepare changes to error code handling

This commit is contained in:
2026-04-28 17:45:59 +01:00
parent 5bbffcecb8
commit 16d929fad1
2 changed files with 4 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
<div class="error-wrapper"> <div class="error-wrapper">
{#if page.status == 20} {#if page.status == 20}
<!-- Check the values passed in the ApiError object and decide what to present -->
<img class="err-img" src={noResult} alt="" role="presentation" width="200" height="200" /> <img class="err-img" src={noResult} alt="" role="presentation" width="200" height="200" />
{:else} {:else}
<img class="err-img" src={stopErr} alt="" role="presentation" width="150" height="210" /> <img class="err-img" src={stopErr} alt="" role="presentation" width="150" height="210" />

View File

@@ -23,7 +23,7 @@ export const load: PageLoad = async ({ url }) => {
const response = await OwlClient.trains.getByHeadcode(headcode, date, toc); const response = await OwlClient.trains.getByHeadcode(headcode, date, toc);
// Shouldn't be needed to cast the type... // Shouldn't be needed to cast the type...
const results = (response.data || []); const results = (response.data);
return { return {
title: headcode.toUpperCase(), title: headcode.toUpperCase(),
results: results, results: results,
@@ -35,7 +35,8 @@ export const load: PageLoad = async ({ url }) => {
owlCode: 'VALIDATION_ERROR', owlCode: 'VALIDATION_ERROR',
}); });
} else if (e instanceof ApiError) { } else if (e instanceof ApiError) {
console.log(e); // Check if NO_RESULTS error, and return empty array if that is the case
// Maybe adjust the resulting error depending on the ERROR Code?!
throw error(20, { throw error(20, {
message: e.message, message: e.message,
owlCode: 'API_ERROR', owlCode: 'API_ERROR',