UNPKG

@directus/api

Version:

Directus is a real-time API and App dashboard for managing SQL database content

12 lines (11 loc) 521 B
import { createError, InternalServerError } from '@directus/errors'; import { defineOperationApi } from '@directus/extensions'; const FALLBACK_ERROR = new InternalServerError(); export default defineOperationApi({ id: 'throw-error', handler: ({ code, status, message }) => { const statusCode = parseInt(status); const error = createError(code ?? FALLBACK_ERROR.code, message ?? FALLBACK_ERROR.message, isNaN(statusCode) ? FALLBACK_ERROR.status : statusCode); throw new error(); }, });