Uploaded image for project: 'AeroGear'
  1. AeroGear
  2. AEROGEAR-948

Default Error Route only supports "text/html"

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • Major
    • 1.0.0.CR1
    • 1.0.0.CR1
    • controller
    • None

    Description

      The issue was reported by Bruno while working on the TODO app. The issue was that in a Route endpoint a NPE was thrown which was an error in the application and not the controller. But the problem was that the error given was regarding not having a responder for the requested media type, which in this case was "application/json".
      What was happening was that the ErrorHandler caught the exception and since there was no error route explicitly defined, the default ErrorRoute was used. The default ErrorRoute produces "text/html". All responses are handled by the same class which is called Responders. The HTTP "Accept" header is specified by the client and is the type of content it wants to receive. But if the route in question is not configured to produce that media type the following exception will be thrown:

      @LogMessage(level = Logger.Level.ERROR)
      @Message(id = 11, value = "No Responder was found that matched the Accept Header: '%s'. The following Responders are registered: '%s'")
      RuntimeException noResponderForRequestedMediaType(String acceptHeader, Responders responders);
      

      This task should enable the accept header from the request to be taken into consideration returning an error response.

      As a workaround an error route could be added that produces JSON but it is hard to know the cause of the actual error at the moment which is a borderline bugg.

      Attachments

        Activity

          People

            dbeveniu Daniel Bevenius (Inactive)
            dbeveniu Daniel Bevenius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: