Kbase P27492: How to use the value obtained by getErrorCode() method of ja
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/25/2003 |
|
Status: Unverified
GOAL:
How to use the value obtained by getErrorCode() method of javax.jms.JMSException class?
FACT(s) (Environment):
SonicMQ
FIX:
Always use the error code by name, not value.
Error code values are internal to the product and can change without any notice. However, its reference by name will never change. Therefore
error == progress.message.jclient.ErrorCodes.ERR_GENERAL_SECURITY_ERR will always work. And error == 10 may not always work.
A Java code that does some error correction should do something like
import progress.message.jclient.ErrorCodes;
.
.
.
// Got the JMS Exception - anException
String jmsErrorCode = anException.getErrorCode();
if (jmsErrorCode != null)
{
try
{
int error = Integer.parseInt(jmsErrorCode);
// now you have the int value of the
// error code, you can do something like
if (error == ERR_GENERAL_SECURITY_ERR)
{
// do your logic here.
// You can also use gswitchh instead of gifh.
}
}
catch (NumberFormatException nfe)
{
// If not a number, it doesn't match.
}
}
What someone should not do is access the variable by its gvalueh instead of is published gnamed referenceh.
Therefore,
if (error == 10)
{
// do your logic here.
}
is not a recommended way of handling the error.
You donft have to write the code mentioned above, Sonic makes things easier for you. Sonic does provide easy of doing error handling. Consider the code below:
import progress.message.jclient.ErrorCodes;
.
.
.
try
{
// do something
}
catch (JMSException anException)
{
if(progress.message.jclient.ErrorCodes.testException(anException, ERR_GENERAL_SECURITY_ERR))
{
// do your logic here.
// You can handle security exception here.
// You can also use gswitchh instead of gifh.
}
}