(error: string | Error | Partial<NuxtError<DataT>>)
| 70 | |
| 71 | /** @since 3.0.0 */ |
| 72 | export const createError = <DataT = unknown>(error: string | Error | Partial<NuxtError<DataT>>) => { |
| 73 | if (typeof error !== 'string' && (error as Partial<NuxtError<DataT>>).statusText) { |
| 74 | error.message ??= (error as Partial<NuxtError<DataT>>).statusText |
| 75 | } |
| 76 | |
| 77 | const nuxtError: NuxtError<DataT> = createH3Error<DataT>(error) |
| 78 | |
| 79 | Object.defineProperty(nuxtError, NUXT_ERROR_SIGNATURE, { |
| 80 | value: true, |
| 81 | configurable: false, |
| 82 | writable: false, |
| 83 | }) |
| 84 | |
| 85 | // #34165 - TODO: remove in Nuxt 5 when statusCode/statusMessage are removed |
| 86 | Object.defineProperty(nuxtError, 'status', { |
| 87 | // eslint-disable-next-line @typescript-eslint/no-deprecated |
| 88 | get: () => nuxtError.statusCode, |
| 89 | configurable: true, |
| 90 | }) |
| 91 | Object.defineProperty(nuxtError, 'statusText', { |
| 92 | // eslint-disable-next-line @typescript-eslint/no-deprecated |
| 93 | get: () => nuxtError.statusMessage, |
| 94 | configurable: true, |
| 95 | }) |
| 96 | |
| 97 | return nuxtError |
| 98 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…