diff --git a/src/api.ts b/src/api.ts index b9673b626..dc56ab6cb 100644 --- a/src/api.ts +++ b/src/api.ts @@ -38,19 +38,19 @@ export async function get( } }); } catch (err) { - throw new ApiError(urlString, "API request failed"); + throw new ApiError("API request failed", urlString); } if (! response.ok) { - throw new ApiError(urlString, "Not found"); + throw new ApiError("Not found", urlString); } return response.json(); } -class ApiError extends Error { - url: string; +export class ApiError extends Error { + url?: string; - constructor(url: string, message: string) { + constructor(message: string, url?: string) { super(message); if (Error.captureStackTrace) { diff --git a/src/base/projects/History.svelte b/src/base/projects/History.svelte index c0d76585a..84937c5ba 100644 --- a/src/base/projects/History.svelte +++ b/src/base/projects/History.svelte @@ -3,6 +3,7 @@ import type { Project } from "@app/project"; import Loading from "@app/Loading.svelte"; import { groupCommitHistory, GroupedCommitsHistory } from "@app/commit"; + import Message from "@app/Message.svelte"; export let project: Project; export let commit: string; @@ -66,8 +67,12 @@ {:catch err}
{err.url} failed.
+ {:else}
+ {err.message}
+ {/if}
+