English

How To: Trap errors using only the number

Summary

Instructions provided describe how to trap errors using only the number. SOAP error messages always begin with an error number. Although the error message text may be updated, the meaning and the error number always remain the same. The application should search only for error message numbers.

Procedure

Within the try/catch block, verify the error message begins with a certain error number.

For example, to check if the exception ex is error #6001:

VB.NET:

Code:
If ex.Message.StartsWith("6001:") Then
'Put the friendly error message here
End If


C#:

Code:
if (ex.Message.StartsWith("6001:")){
//Put the friendly error message here.
}


Java:

Code:
if (ex.getException().getMessage().startsWith("6001:")){
//Put the friendly error message here.
}