IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

Any way to set an error message manually?

  • 1.  Any way to set an error message manually?

    Posted 02/28/11 10:35 AM

    I am using a Try/Catch sequence in a flow. I would like to be able to set an error message manually when certain checks fail, and use getlastError() in the catch block.

    Is there any way to manually set an error structure and then retrieve that information using getLastError()?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: Any way to set an error message manually?

    Posted 02/28/11 03:49 PM

    Write a Java service to accept a message and throw a ServiceException.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: Any way to set an error message manually?

    Posted 02/28/11 03:56 PM


  • 4.  RE: Any way to set an error message manually?

    Posted 02/28/11 07:21 PM

    you can also use exit step and use signal failure with the required message.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 5.  RE: Any way to set an error message manually?

    Posted 02/28/11 09:08 PM

    IME, the exit and signal failure does not always populate the right structures so that getLastErrorMessage returned the error. Thus, when I need to throw an exception I call a Java service that throws a ServiceException.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 6.  RE: Any way to set an error message manually?

    Posted 03/01/11 08:03 PM

    The PSUtilities package includes a Java service, throwError, that demonstrates how to throw a ServiceException as Rob explained. Here is a sample one that I have used before:
    IDataCursor pipelineCursor = pipeline.getCursor();
    String errorMessage = IDataUtil.getString( pipelineCursor, “errorMessage” );
    String strErrorMessage = null;
    if ( errorMessage != null ) {
    strErrorMessage = errorMessage;
    }
    pipelineCursor.destroy();
    throw new ServiceException(strErrorMessage)


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: Any way to set an error message manually?

    Posted 03/02/11 09:20 PM

    Hi,

    You can also use service WmPublic/pub.flow:throwExceptionForRetry and just give error message you want ti see in last error

    Regards,
    Yahya


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 8.  RE: Any way to set an error message manually?

    Posted 03/07/11 05:40 AM

    In the try block, I just update a pipeline variable called (say), ‘someErrorVariable’, then exit the flow with failure.

    In the catch block, after calling getLastError, I access the error variable in the pipeline in this manner:

    
    %lastError/pipeline/someErrorVariable%

    This has worked well so far. Do the problems mentioned apply to this approach too?


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 9.  RE: Any way to set an error message manually?

    Posted 03/09/11 09:37 AM

    Tried that, but even when I declared variables in the pipeline outside the try/catch block, I couldn’t access them from the catch block for some reason.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 10.  RE: Any way to set an error message manually?

    Posted 03/16/11 02:02 PM

    pipeline from try block is accessible in catch block under ‘lastError/pipeline’ as mentioned by sonam also …


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 11.  RE: Any way to set an error message manually?

    Posted 03/16/11 04:39 PM

    Do you mean they don’t appear in the pipeline pane in Developer? Or that at runtime they are not present?


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB