{$I ABSVer.inc}

unit ABSExcept;

interface

uses SysUtils, Classes, ABSConst;

type


////////////////////////////////////////////////////////////////////////////////
//
// EABSException
//
////////////////////////////////////////////////////////////////////////////////


  EABSException = class( Exception )
  public
    NativeError: Integer;
    constructor Create(NativeErrorCode: Integer; ErrorMsg: string); overload;
    constructor Create(NativeErrorCode: Integer; ErrorMsg: string; const Args: array of const); overload;

  end; // EABSException

implementation


//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
constructor EABSException.Create(NativeErrorCode: Integer; ErrorMsg: string);
var
  ErMessage: string;
begin
  NativeError := NativeErrorCode;
  ErMessage := ErrorMsg;
  ErMessage := ErMessage + ' - Native error: '+ Format('%.5d',[NativeErrorCode]);
  inherited Create(ErMessage);
end; // Create


//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
constructor EABSException.Create(NativeErrorCode: Integer; ErrorMsg: string; const Args: array of const);
var
  ErMessage: string;
begin
  NativeError := NativeErrorCode;
  try
    ErMessage := Format(ErrorMsg, Args);
  except
    ErMessage := ErrorMsg + ' Arguments are invalid!';
  end;
  ErMessage := ErMessage + ' - Native error: ' + Format('%5d',[NativeErrorCode]);
  inherited Create(ErMessage);
end; // Create


end.
