function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jeselonjeselon 

Question on ExceptionCode

I'm using the Partner WSDL in a VB.NET development environment.  I was looking through the sforce API documentation and noticed that the Login samples provide different ways of catching exceptions between Java and C#.  Looking at the sample code below, Java seems to be more specific as far as its ability to distinguish the exceptions, with the use of ExceptionCode:

try
{
loginResult = binding.login(userName, password);
}
catch (LoginFault ex)
{ //The LoginFault derives from AxisFault
ExceptionCode exCode = ex.getExceptionCode();
if (exCode == ExceptionCode.INVALID_LOGIN...

In .NET, the closest method I saw to be similar to .getExceptionCode() is .GetBaseException().  However, I am unable to create an ExceptionCode object, nor am I able to make a reference such as "ExceptionCode.INVALID_LOGIN".

The Java sample distinguishes between a login error caused by an invalid user id and password vs. other faults (it seems like there numerous Exception Codes that can be considered as the cause for an invalid userid and password).  I would like to do this as well in VB.NET, in order to display a more informed error message to the user.

Any help would be appreciated.  Thank you.

DevAngelDevAngel

Hi jeselon,

Well, I reckon .Net tries to make determinations about things in the wsdl that are defined and "not used" in any operations.  The problem is that the exception codes ARE used as a fault output in the operation definition and .Net does not recognize this.

For our next release, we are going to move the exception code up to the faultCode level.  But I'm not sure that this will result in a generated enum of exception codes.