I have faced this situation for a while and found solution.
1.Create your custom Exception say (custom exception)
2. Set the properties like errorcode,errormessage, and throwable (if u want to bubble up the exceptions).
3. Create a custom object to hold the results (i.e like a java bean)
4. In your custom component methods just return the custom object and set exception as a property.
for e.g.
public class CustomReturn {
private String result;
private CustomException exception;
//getters & setters
}
public class CustomException {
private int errorCode = -1;
private String errorMessage;
private Throwable error;
//getters & setters
}
public class CustomClass {
public CustomReturn testValue() {
CustomReturn returnValue = new CustomReturn();
try {
//perform operations
}
catch(Exception ex) {
CustomException cex = new CustomException ();
cex .setErrorCode(1000);
cex .setErrorMessage(ex.getMessage());
cex .setErr(ex);
returnValue .setException(cex);
}
return returnValue;
}
}
return returnValue;
As you see , you can check for the exception in your return type using the bean property.
This will overcome the limitation of not able to retrieve the error stack incase of errors with default livecycle components.
Hope this helps.
-Senthil