Pinned topicIntentionally throw exception or raise error

‏2010-07-28T23:44:21Z
|Tags:

Answered question
This question has been answered.

Unanswered question
This question has not been answered yet.

Has anyone come up with a way to intentionally throw an exception with a custom error message that will get caught by a global catch? Right now I have a chain of web service calls and I don't want to configure separate email alerts for each one of them. I'd rather be able to throw an exception with a custom error message to be caught by my global try/catch/email.
Has anyone come up with a workaround for this? I'm thinking that maybe an invalid sql query with the error message written into the invalid statement would get returned by the database connector and be included in the fault info.

In my use case, when the web

‏2010-08-20T20:49:08Z

This is the accepted answer.
This is the accepted answer.

In my use case, when the web service returns data indicating a failure, it does not cause an invokation failure in Cast Iron, so it can't be caught by a catch activity.
I need to be able to do something in Cast Iron that would be the equivalent of this in Java:
throw new MyException("optional text here");
Maybe this could be done with a javascript function and a map variables activity. The error indicator value from the web service and the error message could be passed to the custom function as parameters.

Perspective

‏2010-08-20T21:08:16Z

This is the accepted answer.
This is the accepted answer.

tponthieux,
If your webservice is returning an object with a failure indicator in it, you can just return a fault or (and i hate this part) dupe the catch all branch in line with an if.
If your projects are set up as webservices you can add expected soap faults and then just return one of those.
I have longed for ye old "throw ex", instead i have the copy and paste log error and return.
David

I tried the idea of using a

‏2010-08-21T00:47:29Z

This is the accepted answer.
This is the accepted answer.

I tried the idea of throwing the error in a custom function and it works. The orchestration stops and the fault data catches the error message. The function can be used right in the output map of the web service call. :)

Re: I tried the idea of using a

I tried the idea of throwing the error in a custom function and it works. The orchestration stops and the fault data catches the error message. The function can be used right in the output map of the web service call. :)