Creates a NextResponse for an error, or delegates to a custom onError handler if provided. Used internally by auth routes for consistent error handling.
onError
HTTP status code.
Error message body.
Optional
Optional custom handler; if it returns a Response, that is used instead of the default.
NextResponse with the given status and message, or the custom handler's response.
Creates a NextResponse for an error, or delegates to a custom
onErrorhandler if provided. Used internally by auth routes for consistent error handling.