2 Replies Latest reply on Sep 26, 2013 5:34 AM by ohnishi

    About handling validation failure

    ohnishi

      Hi,

       

      Can I distinguish validation exceptions from the other exceptions?

      For example, when using RESTEasy binding, I would like to return HTTP status code 400 for an invalid request and 500 for an unexpected error.

        • 1. Re: About handling validation failure
          kcbabo

          You can use a custom context mapper to set the HTTP status code to the value you require.  There's not a specific way to distinguish between a validation error and other errors, but you could  run a regex on the error message to test for text specific to validation errors.

          • 2. Re: About handling validation failure
            ohnishi

            Hi Keith, thank you for your reply.

            Do you have a plan to support distinguishing between a validation error and other errors in the future?