Custom Error Messages

URL: /admin/error-messages

Errors happen. Users should know when errors are happening, but we want to provide them with useful guidance and messaging when errors to occur. The API generally returns 4 types of errors:

Upon navigating to the Error Message admin page, you'll see this:

Error Messages Admin Area

Let's observe the following:

  1. You can filter by name.
  2. Add Error Message button - will bring up the Add form to add a new 400 error message handler.
  3. Test 500 Error button - will simulate an internal server error.
  4. Test 400 Bad Request button - will simulate a 400 Bad request that will invoke the sample handler "Test Bad Request" that is set up already in the screenshot.
  5. Test 404 Not Found button - will simulate a 404 not found response from the API.
  6. Search Results - The list of error messages filtered by the search form at the top of the page.

Automated 500 Internal Server Error Handling

When a 500 Internal Server error occurs, an administrator will be emailed details about the issue. The recipients for automatic error messages is configured in the API's appsettings.json file.

Here is a sample of what an automated error message email looks like:

Automated Error Email Message

However, for security and usability reasons, we don't want to show the user any details about an error, but simply that someone has been made aware of the issue and what to do if they need further assistance. Clicking the "Test 500 Error" button will invoke a server error and show the following message:

User Error Message

Guided 400 Bad Request Error Handling

The Custom Error Messages that are configurable through this admin area are intended to offer guidance and further instructions to users who submit a bad request. Below is an example of a custom dialog that handles the sample error message that is setup by default by clicking the "Test 400 Bad Request" button:

Test 400 Error Message

Configuring Custom Error Messages for Bad Request Error Handling

When clicking on the Edit option next to the Test Bad Request that is there by default, we see the following data entry form:

Custom Error Message Data Entry Form

Here's a description of the form fields:

404 Not Found Error Handling

Currently, we don't do anything about reporting 404 errors, but we do let the user know that something went wrong:

Test 404 Error Message