mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 07:49:10 +02:00
* Promoted errorcode to the EDatabaseError level, unified all error codes
git-svn-id: trunk@29118 -
This commit is contained in:
parent
8808308843
commit
2134e3aaac
@ -2393,7 +2393,7 @@ begin
|
||||
if Response = rrApply then dec(r);
|
||||
end
|
||||
else if Response = rrAbort then
|
||||
Raise EUpdateError.Create(SOnUpdateError,E.Message,0,0,Exception(AcquireExceptionObject));
|
||||
Raise EUpdateError.Create(SOnUpdateError,E.Message,E.ErrorCode,0,Exception(AcquireExceptionObject));
|
||||
end
|
||||
else
|
||||
raise;
|
||||
|
@ -78,11 +78,18 @@ type
|
||||
|
||||
{ Exception classes }
|
||||
|
||||
EDatabaseError = class(Exception);
|
||||
{ EDatabaseError }
|
||||
|
||||
EDatabaseError = class(Exception)
|
||||
Protected
|
||||
FErrorCode: integer;
|
||||
Public
|
||||
Property ErrorCode: integer Read FErrorCode;
|
||||
end;
|
||||
|
||||
EUpdateError = class(EDatabaseError)
|
||||
private
|
||||
FContext : String;
|
||||
FErrorCode : integer;
|
||||
FOriginalException : Exception;
|
||||
FPreviousError : Integer;
|
||||
public
|
||||
@ -90,7 +97,6 @@ type
|
||||
ErrCode, PrevError : integer; E: Exception);
|
||||
Destructor Destroy; override;
|
||||
property Context : String read FContext;
|
||||
property ErrorCode : integer read FErrorcode;
|
||||
property OriginalException : Exception read FOriginalException;
|
||||
property PreviousError : Integer read FPreviousError;
|
||||
end;
|
||||
|
@ -26,9 +26,9 @@ type
|
||||
ServerVersionString : string; //Complete version string, including name, platform
|
||||
end;
|
||||
|
||||
EIBDatabaseError = class(EDatabaseError)
|
||||
public
|
||||
GDSErrorCode : Longint;
|
||||
EIBDatabaseError = class(ESQLDatabaseError)
|
||||
public
|
||||
property GDSErrorCode: integer read FErrorCode Write FErrorCode;
|
||||
end;
|
||||
|
||||
{ TIBCursor }
|
||||
|
@ -140,7 +140,7 @@ type
|
||||
|
||||
EMSSQLDatabaseError = class(ESQLDatabaseError)
|
||||
public
|
||||
property DBErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of DBErrorCode'; // Feb 2014
|
||||
property DBErrorCode: integer read FErrorCode; deprecated 'Please use ErrorCode instead of DBErrorCode'; // Feb 2014
|
||||
end;
|
||||
|
||||
{ TMSSQLConnectionDef }
|
||||
|
@ -31,7 +31,7 @@ const
|
||||
type
|
||||
EOraDatabaseError = class(ESQLDatabaseError)
|
||||
public
|
||||
property ORAErrorCode: integer read ErrorCode; deprecated 'Please use ErrorCode instead of ORAErrorCode'; // June 2014
|
||||
property ORAErrorCode: integer read FErrorCode; deprecated 'Please use ErrorCode instead of ORAErrorCode'; // June 2014
|
||||
end;
|
||||
|
||||
TOracleTrans = Class(TSQLHandle)
|
||||
@ -332,19 +332,13 @@ end;
|
||||
|
||||
procedure TOracleConnection.HandleError;
|
||||
|
||||
var errcode : sb4;
|
||||
buf : array[0..1023] of char;
|
||||
E : EOraDatabaseError;
|
||||
var
|
||||
errcode : sb4;
|
||||
buf : array[0..1023] of char;
|
||||
|
||||
begin
|
||||
OCIErrorGet(FOciError,1,nil,errcode,@buf[0],1024,OCI_HTYPE_ERROR);
|
||||
|
||||
if (Self.Name <> '') then
|
||||
E := EOraDatabaseError.CreateFmt('%s : %s',[Self.Name,pchar(buf)])
|
||||
else
|
||||
E := EOraDatabaseError.Create(pchar(buf));
|
||||
|
||||
E.ErrorCode := errcode;
|
||||
Raise E;
|
||||
Raise EOraDatabaseError.Create(pchar(buf),Self,ErrCode,'');;
|
||||
end;
|
||||
|
||||
procedure TOracleConnection.GetParameters(cursor: TSQLCursor; ATransaction : TSQLTransaction; AParams: TParams);
|
||||
|
@ -80,11 +80,13 @@ type
|
||||
{ ESQLDatabaseError}
|
||||
|
||||
ESQLDatabaseError = class(EDatabaseError)
|
||||
Private
|
||||
Function GetNamePrefix (comp : TComponent; Fmt: String) :String;
|
||||
public
|
||||
ErrorCode: integer;
|
||||
SQLState : string;
|
||||
constructor CreateFmt(const Fmt: string; const Args: array of const;
|
||||
Comp : TComponent; AErrorCode: integer; ASQLState: string); overload;
|
||||
constructor Create(AMessage: string; Comp : TComponent; AErrorCode: integer; ASQLState: string); overload;
|
||||
end;
|
||||
|
||||
{ TSQLDBFieldDef }
|
||||
@ -741,20 +743,36 @@ end;
|
||||
|
||||
{ ESQLDatabaseError }
|
||||
|
||||
constructor ESQLDatabaseError.CreateFmt(const Fmt: string; const Args: array of const;
|
||||
Comp: TComponent; AErrorCode: integer; ASQLState: string);
|
||||
const CompNameFmt='%s : %s';
|
||||
var Msg: string;
|
||||
Function ESQLDatabaseError.GetNamePrefix(comp: TComponent; Fmt: String): String;
|
||||
|
||||
const
|
||||
CompNameFmt='%s : %s';
|
||||
|
||||
begin
|
||||
if not assigned(Comp) then
|
||||
Msg := Fmt
|
||||
Result := Fmt
|
||||
else if Comp.Name = '' then
|
||||
Msg := Format(CompNameFmt, [Comp.ClassName,Fmt])
|
||||
Result := Format(CompNameFmt, [Comp.ClassName,Fmt])
|
||||
else
|
||||
Msg := Format(CompNameFmt, [Comp.Name,Fmt]);
|
||||
Result := Format(CompNameFmt, [Comp.Name,Fmt]);
|
||||
end;
|
||||
|
||||
constructor ESQLDatabaseError.CreateFmt(const Fmt: string; const Args: array of const;
|
||||
Comp: TComponent; AErrorCode: integer; ASQLState: string);
|
||||
var Msg: string;
|
||||
begin
|
||||
Msg:=GetNamePrefix(Comp,Fmt);
|
||||
inherited CreateFmt(Msg, Args);
|
||||
ErrorCode := AErrorCode;
|
||||
FErrorCode := AErrorCode;
|
||||
SQLState := ASQLState;
|
||||
end;
|
||||
|
||||
constructor ESQLDatabaseError.Create(AMessage: string; Comp: TComponent;
|
||||
AErrorCode: integer; ASQLState: string);
|
||||
begin
|
||||
AMessage:=GetNamePrefix(Comp,AMessage);
|
||||
inherited Create(AMessage);
|
||||
FErrorCode := AErrorCode;
|
||||
SQLState := ASQLState;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user