This project is read-only.

Exception handling in webapi

Topics: Core, General
Nov 7, 2014 at 8:26 PM

I am on Orchard 1.7.2. I have a web api controller with HandleError attribute on it.

In this controller I throw exceptions if the posted data is not confirming the requirement. I noticed that these exceptions are not caught by the action filters and not logged in the log file.

Exceptions thrown from the non-api controllers are caught and logged.

Now the problem is, the transaction is not cancelled since the action filters are not activated.
Nov 8, 2014 at 8:59 PM
API exceptions are logged in Orchard currently, was added in 1.8 I think. This is implemented in Orchard.Framework.WebApi.Filters, what you can simply copy to your 1.7.2 solution and thus backport it as far as I know.
Jan 24, 2015 at 3:04 PM
i'm using 1.8.1, exception in webapi doesnt trigger the exception filter.
thus, the transaction got committed. :)

any idea how to solve this?
Jan 24, 2015 at 7:26 PM
Indeed. Would you mind submitting a bug? BTW you can work around this by implementing your own unhandled exception filter.
Jan 25, 2015 at 2:19 AM
submitted.thx piedone.

how do i register the exception filter?