networkError
Wraps a caught fetch failure (where no HTTP response was received) into the same ApiError shape returned by parseResponseError. Use it inside a catch block when error.name === 'TypeError' — the typical signature of an offline/DNS/CORS failure.
Signature
import { networkError } from '@conduction/nextcloud-vue'
try {
await fetch(url, { headers: buildHeaders() })
} catch (err) {
if (err.name === 'TypeError') {
state.error = networkError(err)
}
}
Parameters
| Arg | Type | Description |
|---|---|---|
error | Error | The caught exception from fetch. |
Returns — ApiError
{
status: 0, // 0 signals "no HTTP response"
message: error.message || 'A network error occurred. Check your connection and try again.',
details: null,
isValidation: false,
fields: null,
toString(): string, // returns `message`
}
Related
- parseResponseError — For errors where a
Responseis returned. - genericError — For non-network exceptions.