Errors
API error type + toast helper, keyed off the server's
structured error envelope { success:false, error:{ code, message, details } }.
Classes¶
ApiError¶
Defined in: src/shared/api/errors.ts:16
An error thrown for non-2xx API responses (or a request that never reached the
server). code is the server's machine-readable identifier from the error
envelope, when present. displayMessage marks whether message is safe to
show to the user — true for server-envelope messages and intentional
client-side messages, false for a generic fallback synthesised from a
non-envelope body (e.g. a static host's 404 HTML), which must never be shown.
Extends¶
Constructors¶
Constructor¶
Defined in: src/shared/api/errors.ts:17
Parameters¶
| Parameter | Type | Default value |
|---|---|---|
status |
number |
undefined |
message |
string |
undefined |
code? |
string |
undefined |
details? |
unknown |
undefined |
displayMessage? |
boolean |
true |
Returns¶
Overrides¶
Properties¶
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
code? |
public |
string |
undefined |
src/shared/api/errors.ts:20 |
details? |
public |
unknown |
undefined |
src/shared/api/errors.ts:21 |
displayMessage |
public |
boolean |
true |
src/shared/api/errors.ts:22 |
status |
public |
number |
undefined |
src/shared/api/errors.ts:18 |
Functions¶
toastApiError()¶
Defined in: src/shared/api/errors.ts:71
Displays an API error as a toast, preferring the server's machine-readable
code, then an explicit (envelope/client) message, then the HTTP status.
Never shows a raw non-envelope body.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
err |
unknown |
The error to display. |
toastId? |
string |
An existing toast id to update. |
Returns¶
void