genericError
Wraps an arbitrary caught exception into the same ApiError shape returned by parseResponseError and networkError. Use it as the default fallback in a catch block when neither a Response nor a network TypeError is available.
Signature
import { genericError, networkError } from '@conduction/nextcloud-vue'
try {
await somethingThatMightThrow()
} catch (err) {
state.error = err.name === 'TypeError'
? networkError(err)
: genericError(err)
}
Parameters
| Arg | Type | Description |
|---|---|---|
error | Error | The caught exception. |
Returns — ApiError
{
status: null, // unknown — neither an HTTP status nor a network failure
message: error.message,
details: null,
isValidation: false,
fields: null,
toString(): string,
}
Related
- parseResponseError — For HTTP response errors.
- networkError — For fetch
TypeErrorfailures.