Sign in

Handler Type: PageOnError

PageOnError = (req: NextApiRequest, res: NextApiResponse, error: Error) => Promise<void> | void

Handler invoked when an error occurs during execution of a Pages Router API endpoint.

Allows custom error handling such as logging, modifying the response, or sending a custom error payload.

Parameters

ParameterTypeDescription
reqNextApiRequestThe incoming Next.js API request.
resNextApiResponseThe outgoing Next.js API response.
errorErrorThe error thrown during endpoint execution.

Returns

Promise<void> | void

Returns void or a Promise that resolves when error handling is complete.

© 2024 MonoCloud. All rights reserved.