Official Content

Enables HTTP Error Handlers.

Scope

Level: Environment

Description

This property enables the use of error code handlers to control how to respond when an application error or exception occurs.

When errors occur, the user shouldn't have to read technical error details which they cannot understand; instead, a friendly page that tells them what happened should be displayed. Also, proper handling of errors is recommended to hide sensitive technical information that can be exploited.

How to specify default errors

Enable this property (environment level) and associate an HTTP Error Code to a File previously uploaded to the KB as a File object (using a plain HTML file is recommended). Typically, you might configure the following kind of errors:

  • 401: Unauthorized.
  • 404: Page not found.
  • 405: Method not allowed. A request was made of a page using a request method not supported by that page.
  • 408: Timeout. Server timed out.
  • 500: Internal Server Error.

Considerations

When using the C# generator, valid values are between 400 and 999 inclusive; otherwise, the following error will be displayed:

The 'statusCode' attribute is invalid. Integer value must be between 400 and 999 inclusive.

In general, Java Application servers such as Tomcat will directly handle the 400 (Bad Request) error and it will not be delegated to the web application.

Not implemented in the NetCore generator.

Runtime/Design time

This property applies only at design-time.

Samples

Create a 404.html file with the following content and upload it to the KB; set the extraction location path for your generators.

<!DOCTYPE html>
<html lang="es">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>404 Error - Page Not Found</title>
  </head>
  <body>
    <div class="container">
      <main>
        <h1>Sorry, the page you requested was not found.</h1>
      </main>
    </div>
  </body>
</html>

Configure this property to bind the 404 HTTP error code to the 404.html file.

image_2020624135936_1_png

With this declaration, if any 404 error occurs, your own error page is displayed to the user.

HttpErrorHandler02

Note that your custom error page is relative to the web application’s context root.

How to apply changes

To apply the corresponding changes when the property value is configured, execute a Build All.

Availability

This property is available since GeneXus 16 Upgrade 11.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant