Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

handling exception in custom components


Level 6

Is there any info about handling exceptions in custom components? I would like to expose some exceptions to the Livecycle process.

Thank you
2 Replies


Level 10
Unfortunately there is not a lot of documentation on that area.

This is a quick example I built a while ago. The list of exceptions the function can throw which are JasException (which is a custom exception), and FileNotFoundException are what you're going to see in the list from the lightning bolt.


public void ReadFile(String code) throws JasException,FileNotFoundException{

System.out.println("!!!******** Init Compontent with value " + code);

code = "3";


System.out.println("***** In code 1");

throw new JasException();




System.out.println("***** In code 2");

FileInputStream fstream = new FileInputStream("textfile.txt");



catch (Exception e){

throw new FileNotFoundException();



int intCode = 0;

intCode = intCode /0;


System.out.println("******** End Compontent");



Former Community Member
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.