forked from Sovos-Compliance/convey-public-libs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uECodedError.pas
37 lines (30 loc) · 883 Bytes
/
uECodedError.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
unit uECodedError;
interface
uses
SysUtils;
type
ECodedErrorClass = class of ECodedError;
ECodedError = class(Exception)
private
FErrorCode: Integer;
FErrorMessage: string;
protected
class function ErrorCodePrefix: String; virtual; abstract;
public
constructor Create(AErrorCode : integer; const AMessage : string); overload; virtual;
constructor Create(E: ECodedError); overload;
property ErrorCode: Integer read FErrorCode;
property ErrorMessage: string read FErrorMessage;
end;
implementation
constructor ECodedError.Create(AErrorCode : integer; const AMessage : string);
begin
inherited Create (Format ('(%s-%.4d) %s', [ErrorCodePrefix, AErrorCode, AMessage]));
FErrorCode := AErrorCode;
FErrorMessage := AMessage;
end;
constructor ECodedError.Create(E: ECodedError);
begin
Create (E.ErrorCode, E.ErrorMessage);
end;
end.