cancel
Showing results for 
Search instead for 
Did you mean: 

Using Which Exception we can stop to Call Another Method

Former Member
0 Kudos

Hi Experts,

In my application iam using two methods, iam calling Method A in Method B.

Method A is throwing one exception based on one condition i used wdComponentAPI.getMessageManager().reportInvalidContextAttributeException(

when this exception raised in Method A its showing exception message and its not able to stop to call Method B.

so i called the same exception based on the same condition what i checked in method A,

so in method b also showing exception messages but i want to show only one exception message what to do

plz help me in this

regards,

sush

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Create one context attribute example "Error Displayed" of boolean type and control your code as below.

public void methodA( )
  {
   
   if(validate==false)
    {
    	wdContext.currentContextElement().setErrorDisplayed(true);
               wdComponentAPI.getMessageManager().reportException("Error",true);	
    }
	
  }

   public void methodB( )
  {
    
    methodA();
 
    if(wdContext.currentContextElement().getErrorDisplayed()==false && validate==false)
    {
    wdComponentAPI.getMessageManager().reportException("Error",true);	
    }
  }

Regards,

Charan

Former Member
0 Kudos

Hi,

you may also use some "real" exceptions in your coding. In your outer method place a try-catch block and throw some meaningful exceptions in your inner and outer method.

In the catch do the reporting of the exceptions.

But keep in mind, exceptions are "costly". If you have just an input check on your context, then it maybe better to create a dedicated method for checking your context and other input before you go to any further method.

Hope that helps a little bit,

Frank