Sign in

Handler Type: AppOnError

AppOnError<T> = (req: NextRequest, ctx: T, error: Error) => Promise<NextResponse | void> | NextResponse | void

Handler invoked when an error occurs during execution of an App Router endpoint.

Allows custom error handling such as logging, transforming the response, or returning a custom NextResponse

Type Parameters

Type ParameterDescription
TThe type of the App Router context passed to the handler.

Parameters

ParameterTypeDescription
reqNextRequestThe incoming Next.js request.
ctxTThe App Router context containing dynamic route parameters.
errorErrorThe error thrown during endpoint execution.

Returns

Promise<NextResponse | void> | NextResponse | void

Returns a NextResponse or void.

© 2024 MonoCloud. All rights reserved.