Official Content

Enables HTTP error code handlers to control how to respond when an application error or exception occurs.

Scope

Generators: .NET, .NET Framework, Java
Level: Environment

Description

When errors occur, the user shouldn't have to read technical error details that 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

To configure the property, go to Preferences > Environment.

HttpErrorHanldlersProperty_png

To enable this property, associate an HTTP Error Code to a File previously uploaded to the Knowledge Base as a File object (it is recommended to use a plain HTML file). Typically, you can configure the following error types:

  • 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 .NET Framework 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. 

Also, be sure to always use the "Extract File" option when setting the Http Error Handling property.

When using Spring Boot, you need to name the error pages according to the error code you want to handle. For example, if you want to customize the page for error 404, you should name the file 404.html and for error 500, the file should be 500.html.

For more details, you can refer to the official Spring Boot documentation on Custom error pages.

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 Knowledge Base; 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 end 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.

Last update: June 2025 | © GeneXus. All rights reserved. GeneXus Powered by Globant