diff --git a/app/composables/useAuth.ts b/app/composables/useAuth.ts index a11bca6..7d95bcd 100644 --- a/app/composables/useAuth.ts +++ b/app/composables/useAuth.ts @@ -1,5 +1,15 @@ import type { ZitadelAuth } from "@kuns/zitadel-auth"; +/** API call failure carrying the HTTP status (401 = authenticated but not authorized). */ +export class ApiError extends Error { + constructor( + message: string, + public status: number, + ) { + super(message); + } +} + // Access the bootstrap-provided Zitadel auth instance + a small JSON helper for /api calls. // By the time any component mounts, the plugin has gated auth, so `auth` is authenticated. // `auth.fetch` auto-attaches the Bearer access token. @@ -16,7 +26,7 @@ export function useAuth() { } catch { // non-JSON error body } - throw new Error(message); + throw new ApiError(message, res.status); } if (res.status === 204) return undefined as T; return (await res.json()) as T; diff --git a/app/pages/index.vue b/app/pages/index.vue index 88138c6..819fc54 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -1,7 +1,10 @@