Topic
  • 5 replies
  • Latest Post - ‏2012-04-25T16:20:54Z by jaydeem
SystemAdmin
SystemAdmin
100 Posts

Pinned topic Intentionally throw exception or raise error

‏2010-07-28T23:44:21Z |
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.
Updated on 2012-04-25T16:20:54Z at 2012-04-25T16:20:54Z by jaydeem
  • SystemAdmin
    SystemAdmin
    100 Posts

    Normal 0 false false false Mi

    ‏2010-08-09T22:59:20Z  

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="ProgId" content="Word.Document" />
    <meta name="Generator" content="Microsoft Word 11" />
    <meta name="Originator" content="Microsoft Word 11" />
    <!--if gte mso 9><xml>
    <w:WordDocument>
    <w:View>Normal</w:View>
    <w:Zoom>0</w:Zoom>
    <w:PunctuationKerning/>
    <w:ValidateAgainstSchemas/>
    <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
    <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
    <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
    <w:Compatibility>
    <w:BreakWrappedTables/>
    <w:SnapToGridInCell/>
    <w:WrapTextWithPunct/>
    <w:UseAsianBreakRules/>
    <w:DontGrowAutofit/>
    </w:Compatibility>
    <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
    </w:WordDocument>
    </xml><!endif--><!--if gte mso 9><xml>
    <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
    </w:LatentStyles>
    </xml><!endif--><style>
    <!--
    /* Style Definitions */
    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:"Times New Roman";}
    p.active, li.active, div.active
    {mso-style-name:active;
    mso-margin-top-alt:auto;
    margin-right:0in;
    mso-margin-bottom-alt:auto;
    margin-left:0in;
    mso-pagination:widow-orphan;
    font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:"Times New Roman";}
    Section1
    {size:8.5in 11.0in;
    margin:1.0in 1.25in 1.0in 1.25in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-paper-source:0;}
    div.Section1
    {page:Section1;}
    -->
    </style><!--if gte mso 10>
    <style>
    /* Style Definitions */
    table.MsoNormalTable
    {mso-style-name:"Table Normal";
    mso-tstyle-rowband-size:0;
    mso-tstyle-colband-size:0;
    mso-style-noshow:yes;
    mso-style-parent:"";
    mso-padding-alt:0in 5.4pt 0in 5.4pt;
    mso-para-margin:0in;
    mso-para-margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    font-size:10.0pt;
    font-family:"Times New Roman";
    mso-ansi-language:#0400;
    mso-fareast-language:#0400;
    mso-bidi-language:#0400;}
    </style>
    <!endif-->If
    one of the activities error out in a Cast Iron orchestration, the job stops
    processing the further activities and the error is caught by the ‘Catch’
    branch.  So if you have a series of Web Service Invoke activities to
    invoke a chain of web service calls, when one of them fails, the subsequent
    activities does not get executed. The Job errors out and the error is caught by
    ‘Catch’ branch, and an email can be sent out.

     

    Thanks,

    Vani. 










  • SystemAdmin
    SystemAdmin
    100 Posts

    In my use case, when the web

    ‏2010-08-20T20:49:08Z  
    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.
  • SystemAdmin
    SystemAdmin
    100 Posts

    Perspective

    ‏2010-08-20T21:08:16Z  
    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
  • SystemAdmin
    SystemAdmin
    100 Posts

    I tried the idea of using a

    ‏2010-08-21T00:47:29Z  
    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. :)

    //error boolean
    // message
    string
    // returns boolean


    ThrowException(error,message){
    if(error
    ){
    throw message
    ;
    }
    else
    {
    return error
    ;
    }
    }



    Given the data:
    error = true
    message = "This is an error message."
    The fault info returns:
    Fault Message:
    Exception in map activity: This is an error message. (ThrowException#1)



  • jaydeem
    jaydeem
    1 Post

    Re: I tried the idea of using a

    ‏2012-04-25T16:20:54Z  
    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. :)

    //error boolean
    // message
    string
    // returns boolean


    ThrowException(error,message){
    if(error
    ){
    throw message
    ;
    }
    else
    {
    return error
    ;
    }
    }



    Given the data:
    error = true
    message = "This is an error message."
    The fault info returns:
    Fault Message:
    Exception in map activity: This is an error message. (ThrowException#1)



    Hi
    Great idea.. is it possible though to throw the exception, and populate the fault info?
    Id essentially like to make use of the catch all and log the fault keys

    thanks