Ga naar hoofdinhoud

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

ArgTypeDescription
errorErrorThe 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,
}