You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Manasingarao Shitole <sh...@prime-research.com> on 2017/11/16 10:48:29 UTC

How to configure the ExceptionRecognizer in Isis + how to return different HTTP status codes

Hi all,


We would like to define our own ServiceExceptionRecognizer for following exceptions, ex:

- BadRequestException : map to HTTP 400 with the validation message

- RuntimeException : map to HTTP 500 with the appropriate message.


This will help our clients and wicket viewer as well. Instead of propagating entire stack trace for the expected recoverable errors.


To do that, here is the exception recognizer


public class ServiceExceptionRecognizer extends ExceptionRecognizerForType {
    public ServiceExceptionRecognizer(){
        super(Category.CLIENT_ERROR, ofTypeIncluding(BadRequestException.class, new String[]{"Only long comma separated values allowed"}), prefix("Bad Request"));
    }
}

Now the question is how to configure the same, tried setting below property in isis.properties but it doesn't recognize:
isis.services=com.isis.modules.source.dom.exception.ServiceExceptionRecognizer

Where as Isis document says you cant put "isis.services" along with "isis.appManifest"
isis.appManifest=com.isis.application.manifest.DomainAppAppManifest

If we remove the "isis.appManifest" then application will fail to bootstrap.

Of-course I havn't understood correctly and going somewhere wrong. I dont find any clue in docs nor there are any examples on that.
Could someone guide us with examples, that will be of great help.

Thank you in anticipation.

Kind regards,
-Mansingh