handleNotFoundException method

  1. @ExceptionHandler(NotFoundException)
Future<View> handleNotFoundException(
  1. ServerHttpRequest request,
  2. ServerHttpResponse response,
  3. WebRequest webRequest,
  4. NotFoundException exception,
)

Handles NotFoundException by rendering an HTTP 404 (Not Found) error view.

Purpose: Informs the client that the requested resource does not exist or is unavailable under the given URI.

View data:

  • message: additional context or reason for the missing resource.

  • requestPath: resolved request path that was not found.

  • errorId: optional tracking identifier for the error.

  • request: the HTTP request that triggered the exception.

  • response: the HTTP response being prepared.

  • webRequest: the web request context.

  • exception: the thrown NotFoundException.

Returns a View generated by ErrorPageUtils.notFound.

Implementation

@ExceptionHandler(NotFoundException)
Future<View> handleNotFoundException(
  ServerHttpRequest request,
  ServerHttpResponse response,
  WebRequest webRequest,
  NotFoundException exception
) async => ErrorPageUtils.notFound(
  message: exception.message,
  requestPath: exception.uri?.path ?? request.getRequestURI().path,
  errorId: exception.details?['errorId'] as String?,
);