Carry Custom Error From One BPL to Another BPL
Hello,
I'm trying to carry a custom error from one business process to another.
BPL:LookupClass fails it's lookup and a custom error of "Lookup XYZ" is generated.
The class quits with that error, but upon quitting, the custom error gets wrapped in an Ensemble System error:
ERROR <Ens>ErrBPTerminated: Terminating BP LookupClass # due to error: Lookup XYZ
This means, when I use the %LastError property to get the error message, it's not got the value I want to use. In this case, "Lookup XYZ". It instead has "Terminating BP LookupClass # due to error: Lookup XYZ"
Is there a way to prevent the Ensemble System error triggering between the two classes so I can use the custom error message?
Thank you for taking the time to read!
Comments
You cannot prevent %LastError from being a %Status; in BPL, %LastError always contains a %Status value, and if you want the text from it you should extract it with $System.Status methods such as GetOneStatusText() and optionally GetErrorCodes(). [1][2][3][4]
If you want to carry your own custom value between BPL scopes/processes, the BPL documentation points to using a thrown fault string rather than relying on %LastError text. A <throw> sends a string fault value, and in the fault handler you can read that value from %LastFault. [1][2][3][4]
Specifically, when a <throw> executes, its fault value is “an expression that evaluates to a string,” and if it reaches a <catchall>, the example shows %LastFault containing “the text derived from the fault expression from the <throw> statement.” [1][2][3][4]
So for your case, instead of quitting with a custom error and then reading %LastError, use a BPL <throw fault='"Lookup XYZ"'/> pattern and handle it with <catch> or <catchall>, then read ..%Context.%LastFault to get exactly your custom text such as Lookup XYZ. [1][2][3][4]
Note: If a
Sources: