home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d45 / ARDOCI.ZIP / OraError.pas < prev    next >
Pascal/Delphi Source File  |  2001-03-01  |  1KB  |  46 lines

  1. unit OraError;
  2.  
  3. interface
  4.  
  5. uses SysUtils, OraDefines;
  6.  
  7. type
  8.   EOraError = class(Exception)
  9.   private
  10.    FErrorType:sword;
  11.    FErrorCode:sb4;
  12.    FErrorText:string;
  13.   public
  14.    constructor Create(EType:sword;ECode:sb4;EText:string);
  15.    destructor Destroy;override;
  16.    property ErrorType:sword read FErrorType;
  17.    property ErrorCode:sb4 read FErrorCode;
  18.    property Text:string read FErrorText;
  19.   end;
  20.  
  21. implementation
  22.  
  23. constructor EOraError.Create(EType:sword;ECode:sb4;EText:string);
  24. begin
  25. // Errors with numbers 20010-20050 are reserved for user information messages (not errors) from database.
  26. //  Cut all debug info (such as error line,name of procedure) from error message text.
  27. //  Leaves only user information message.
  28. //  User information message should have the following format for example
  29. //  Example PL/SQL code how to raise user information message:
  30. //    raise_application_error(-20010,'{You cannot do this operation because ....}');
  31.  
  32.  FErrorText:=EText; // full error text
  33.  FErrorType:=EType;
  34.  FErrorCode:=ECode;
  35.  if (ECode>=20010) and (ECode<=20050) then
  36.   if Pos('{', EText) <> 0 then EText := Copy(EText, Pos('{', EText)+1, Pos('}', EText)-Pos('{', EText)-1);
  37.  inherited Create(EText);
  38. end;
  39.  
  40. destructor EOraError.Destroy;
  41. begin
  42.  inherited Destroy;
  43. end;
  44.  
  45. end.
  46.