problem catching exceptions

Skip to first unread message

Wei Hsu

Feb 27, 2014, 5:36:37 AM2/27/14
Hello, I'm trying to implement an exception handler and am having trouble getting it to work. Can spot what I'm doing wrong?

Thanks, Wei

James Reeves

Feb 27, 2014, 8:49:12 AM2/27/14
to Compojure
A failed assert raises an AssertionError, which does not inherit from the Exception class.

In Java, Throwable is the base error class, and subclassing this are Errors and Exceptions. Errors are for serious problems that the application should not attempt to catch, whereas Exceptions are things your application might want to catch.

An assertion error is an Error, rather than an Exception, because it indicates your application is in an unexpected state.

- James

You received this message because you are subscribed to the Google Groups "Compojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

Wei Hsu

Feb 28, 2014, 11:03:48 PM2/28/14
Thanks, that's spot on. The assertion did alert me to a bug in the application. However, I feel like even unexpected assertion errors should not be exposed to the user in the request body. Would it be good practice to also catch Errors in the wrapper?

James Reeves

Mar 1, 2014, 8:01:42 AM3/1/14
to Wei Hsu, Compojure
Yes, the one time to might want to catch any Throwable is for logging purposes, or to hide the stacktrace from users.

Sorry if I wasn't clear on that.

- James
Reply all
Reply to author
0 new messages