MongocampErrorAlert
Error banner for a failed load. Turns whatever the MongoCamp client threw into a readable message (via useMongocampError) and offers Retry, or Log in again when the session has ended. Renders nothing while error is empty. Used by every list component in this module.
Usage
<script setup lang="ts">
const loadError = ref<unknown>(null)
async function load() {
loadError.value = null
try { /* ... */ }
catch (e) { loadError.value = e }
}
</script>
<template>
<MongocampErrorAlert :error="loadError" @retry="load" />
</template>Props
| Prop | Type | Default | Description |
|---|---|---|---|
error | unknown | — | The caught error; falsy hides the alert |
title | string | Failed to load data | Alert title |
loginPath | string | the module's loginPath option (/) | Where Log in again goes after clearing the session |
filterRejected | boolean | false | Set by a parent that knows the request only fails because of the filter it sent (the server answered it with a 400). Replaces the message with "The filter could not be applied" and the Retry button with Clear filters |
Which message
| Failure | Message | Button |
|---|---|---|
401 — the session has ended | "Your session has expired. Please log in again." | Log in again |
| Network failure (offline, server down) | "The server could not be reached…" | Retry |
403, or any other error | the matching message — for a failure the server explained ({ code, msg } body: a refused operator, an invalid filter, a 404) the server's own message | Retry |
429 with Retry-After (server 2.11 rate limits) | "… Try again in 7 s." | Retry — disabled and counting down ("Retry in 7 s") until the wait is over |
403 code 4033 (server 2.10 access or field rule) | the rule's message ("The access rules of this collection do not allow this.") — never Log in again | Retry |
filterRejected | "The filter could not be applied", followed by "Server message: …" when the server said why (a 400 body), or the field a field rule hides (4033) | Clear filters |
The server's text is read from the failed response itself (see useMongocampError); the message is shown a moment after the alert appears and never contains a database address. No extra request is made to work this out: the server answers a refused token with a readable 401.
Log in again first clears the stored session (through the dependency's logout()) and only then navigates to loginPath. The order matters: while the cookie still holds the dead token the app believes it is logged in, and a login page that redirects logged-in users would bounce straight back.
Events
| Event | Description |
|---|---|
retry | Retry button clicked (not shown for 401 or when filterRejected) |
clearFilters | Clear filters clicked (only shown when filterRejected) |
Request id (server 2.5)
A failed answer of the server (5xx) carries an x-request-id; the alert shows it with a copy button — the key an administrator needs to find the details in the server's log. The server's generic text for an unexpected error becomes The server failed unexpectedly …; a database error keeps its own message.