Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

handling exception in custom components

Avatar

Avatar
Level 6
neptas
Level 6

Likes

0 likes

Total Posts

259 posts

Correct Reply

0 solutions
View profile

Avatar
Level 6
neptas
Level 6

Likes

0 likes

Total Posts

259 posts

Correct Reply

0 solutions
View profile
neptas
Level 6

26-03-2009

Hello,



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



Thank you

Replies

Avatar

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile

Avatar
Coach
Level 10
Jasmin_Charbonn
Level 10

Likes

149 likes

Total Posts

2,154 posts

Correct Reply

97 solutions
Top badges earned
Coach
Give Back 1000
Give back 900
Give Back 800
Give back 600
View profile
Jasmin_Charbonn
Level 10

27-03-2009

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.



Jasmin



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



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

code = "3";



if(code.equalsIgnoreCase("1")){

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

throw new JasException();

}



try{

if(code.equalsIgnoreCase("2")){

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

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

}

}

catch (Exception e){

throw new FileNotFoundException();

}



if(code.equalsIgnoreCase("3")){

int intCode = 0;

intCode = intCode /0;

}



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

}

Avatar

Avatar
Level 2
Sentah
Level 2

Likes

0 likes

Total Posts

29 posts

Correct Reply

0 solutions
View profile

Avatar
Level 2
Sentah
Level 2

Likes

0 likes

Total Posts

29 posts

Correct Reply

0 solutions
View profile
Sentah
Level 2

30-03-2009

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