Chapter 5

Exceptions

This chapter explains the exceptions thrown by some of the CyberSource .NET Client methods.

Depending on your application needs, you may need to review the value of the exception code to determine how best to handle specific error cases.

BugException

This exception is thrown when there is a problem in the code or in the configuration.

BugException has a property called ExceptionCode, which is of type BugExceptionCode.

Table 3 lists the values for BugExceptionCode.

Table 3 BugExceptionCode Values

BugExceptionCode Value

Description

Relevant Properties in the Exception Object

INVALID_ARG

An argument passed to a method is null or invalid.

Message — will have the name of the argument.

INVALID_CONFIG

A property is null or invalid, preventing ICSClient from working properly.

Message — will have the description of the problem.

INVALID_CONFIG_FORMAT

The file or stream passed to ICSClient’s constructor does not contain the correct format.

InnerException — will have the actual exception that occurred.

INVALID_FIELD

A field in the request is null or invalid.

Message — will have the field name and, if not null, its invalid value.

DLL_NOT_FOUND

CybsSecurity.dll could not be found. Copy CybsSecurity.dll to the same location where the assembly CyberSource.dll is. If you have an ASP.NET application, this is usually the bin subdirectory. Otherwise, if you application is an executable, this is usually the same directory where the executable file is located.

InnerException — will have the actual exception that occurred.

INVALID_DLL

The copy of CybsSecurity.dll is invalid. Contact CyberSource Customer Support for a valid copy.

InnerException — will have the actual exception that occurred.

ConfigIOException

This exception is thrown when the loading or saving of the configuration data fails.

ConfigIOException has a property called ExceptionCode, which is of type ConfigIOExceptionCode.

Table 4 lists the values for ConfigIOExceptionCode.

Table 4 ConfigIOExceptionCode Values

ConfigIOExceptionCode Value

Description

Relevant Property in the Exception Object

LOAD

An IO error occurred while loading the configuration properties.

InnerException — will have the actual exception that occurred.

SAVE

An IO error occurred while saving the configuration properties.

InnerException — will have the actual exception that occurred.

CriticalTransactionException

This exception is thrown when an exception occurs after the ICS server has received and possibly processed the request. Since the outcome of the transaction is not known when this exception is thrown, you should check the Enterprise Business Center to determine whether the transaction was processed successfully.

CriticalTransactionException has a property called ExceptionCode, which is of type CriticalTransactionExceptionCode.

Table 5 lists the values for CriticalTransactionExceptionCode.

Table 5 CriticalTransactionExceptionCode Values

CriticalTransactionException-Code Value

Description

Relevant Property in the Exception Object

HTTP_ERROR

An HTTP response other than "200" was returned by the server.

InnerException — will have the actual System.Net.WebException that occurred, whose Response property will have the HttpWebResponse object.

INCOMPLETE_REPLY

The reply received from the server could not be parsed completely.

Message — will have the remaining string in the reply that could not be parsed.

PARSE_REPLY

An error occurred while parsing the reply received from the server.

Message — will say whether it ran out of memory or parsing failed for some other reason, in which case it will also contain the raw reply received from the server.

READ_RESPONSE_STREAM

An error occurred while reading from the Response stream.

InnerException — will have the actual System.IO.IOException that occurred.

RECEIVE

An error occurred while receiving the reply from the server.

InnerException — will have the actual System.Net.WebException that occurred.

TIMEOUT

The request timed out.

InnerException — will have the actual System.Net.WebException that occurred.

UNKNOWN_STATUS

An error occurred while transmitting the request and it could not be determined whether or not the server had received the request.

InnerException — will have the actual System.Net.WebException that occurred.

LogException

This exception is thrown when the property ThrowLogException in the Client object is set to yes, and an exception occurred during logging.

The property Message will have the entire text that would have been logged if the exception did not occur. The property InnerException will have the actual exception that occurred.

If an exception was being logged when the LogException occurred, the property ExceptionBeingLogged (of type System.ApplicationException) will have this exception.

NonCriticalTransactionException

This exception is thrown when an exception occurs before the ICS server has received the entire request.

NonCriticalTransactionException has a property called ExceptionCode, which is of type NonCriticalTransactionExceptionCode.

Table 6 lists the values for NonCriticalTransactionExceptionCode.

Table 6 NonCriticalTransactionExceptionCode Values

NonCriticalTransaction-ExceptionCode Value

Description

Relevant Properties in the Exception Object

COMPOSE_REQUEST

An error occurred while composing the request.

Message — will say whether it ran out of memory or the composition failed for some other reason.

CONNECT

Could not connect to the server.

InnerException — will have the actual System.Net.WebException object.

GENERATE_REQUEST_ID

Could not generate a request ID.

Message — will have the description of the problem.

InnerException — if applicable, will refer to a System.Net.Sockets.SocketException object.

GET_REQUEST_STREAM

An error occurred while obtaining the request stream.

InnerException — will have the actual System.IO.IOException object.

LOAD_KEY

An error occurred while loading a key.

Message — will have the full path of the key that failed to load.

InnerException — will have the actual System.IO.IOException object.

PROXY_AUTH

Failed to authenticate against the proxy server.

InnerException — will have the actual System.Net.WebException object.

PROXY_CONNECT

An error occurred while connecting to the proxy server.

InnerException — will have the actual System.Net.WebException object.

SEND

An error occurred while sending the request to the server.

InnerException — will have the actual System.Net.WebException object.

WRITE_REQUEST_STREAM

An error occurred while writing to the request stream.

InnerException — will have the actual System.Net.WebException object.