OracleException behavior

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Dennis Wanke
Posts: 57
Joined: Tue 11 Mar 2014 07:49

OracleException behavior

Post by Dennis Wanke » Tue 06 May 2014 12:22

The behavior of OracleException is inconsistent with that of SqlException. The OracleException's Errors property can be null, whereas the SqlException's one can never be null and always contains at least one entry. Moreover, SqlException.Message comprises all the messages from the Errors collection (separated with a new line), which OracleException doesn't:

Code: Select all

public SqlErrorCollection Errors
{
    get
    {
        if (this._errors == null)
            this._errors = new SqlErrorCollection();
        return this._errors;
    }
}

static SqlException CreateException(SqlErrorCollection errorCollection, ...)
{
    var stringBuilder = new StringBuilder();
    for (int index = 0; index < errorCollection.Count; ++index)
    {
        if (index > 0) stringBuilder.Append(Environment.NewLine);
        stringBuilder.Append(errorCollection[index].Message);
    }
    ... ...
    return new SqlException(((object) stringBuilder).ToString(), ...);
}
This differences can lead to hidden bugs when implementing error handling involving OracleException by persons who are familiar with "handling" SqlException (which actually doesn't require any special handling for bringing up all the messages, in opposite to OracleException).
So please consider making OracleException's behavior to be consistent with that of SqlException. Note, if message concatenation will be implemented, that only distinct messages should be taken, in order to suppress duplicating messages for different data rows (like when multiple constraint checks fail upon closing OracleLoader).

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: OracleException behavior

Post by Pinturiccio » Thu 08 May 2014 13:49

We will investigate the possibility to implement behavior compatible with the one of SqlException.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: OracleException behavior

Post by Pinturiccio » Wed 14 May 2014 14:25

We have changed the behaviour: the Error property of the OracleException class is never null now and always has at least one element. Additionally, the Message property of the OracleException class now contains all distinct texts of the errors occurred when processing exceptions of the ExecuteArray method and of OracleLoader in the array binding mode. We will post here when the corresponding build of dotConnect for Oracle is available for download.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: OracleException behavior

Post by Pinturiccio » Thu 15 May 2014 14:29

New build of dotConnect for Oracle 8.3.161 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?t=29592

Dennis Wanke
Posts: 57
Joined: Tue 11 Mar 2014 07:49

Re: OracleException behavior

Post by Dennis Wanke » Fri 16 May 2014 18:15

I confirm this is now fixed

Post Reply