75 lines
2.8 KiB
Plaintext
75 lines
2.8 KiB
Plaintext
{*******************************************************}
|
|
{ }
|
|
{ Tocsg.Exception }
|
|
{ }
|
|
{ Copyright (C) 2022 kkuzil }
|
|
{ }
|
|
{*******************************************************}
|
|
|
|
unit Tocsg.Exception;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils;
|
|
|
|
type
|
|
ETgException = class(Exception)
|
|
public
|
|
class procedure TraceException(E: Exception; nLogLv: Integer = 0); overload;
|
|
class procedure TraceException(E: Exception; const sInfo: String; nLogLv: Integer = 0); overload;
|
|
class procedure TraceException(E: Exception; const sFormat: String; const Args: array of const; nLogLv: Integer = 0); overload;
|
|
class procedure TraceException(Sender: TObject; E: Exception; nLogLv: Integer = 0); overload;
|
|
class procedure TraceException(Sender: TObject; E: Exception; const sInfo: String; nLogLv: Integer = 0); overload;
|
|
class procedure TraceException(Sender: TObject; E: Exception; const sFormat: String; const Args: array of const; nLogLv: Integer = 0); overload;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Tocsg.Trace, Tocsg.Obj;
|
|
|
|
class procedure ETgException.TraceException(E: Exception; nLogLv: Integer = 0);
|
|
begin
|
|
TTgTrace.T(Format('ETgException .. %s, Msg="%s"', [E.ClassName, E.Message]), nLogLv);
|
|
end;
|
|
|
|
class procedure ETgException.TraceException(E: Exception; const sInfo: String; nLogLv: Integer = 0);
|
|
begin
|
|
TTgTrace.T(Format('ETgException .. %s, Msg="%s", Info = %s', [E.ClassName, E.Message, sInfo]), nLogLv);
|
|
end;
|
|
|
|
class procedure ETgException.TraceException(E: Exception; const sFormat: String; const Args: array of const; nLogLv: Integer = 0);
|
|
var
|
|
str: String;
|
|
begin
|
|
FmtStr(str, sFormat, Args);
|
|
TraceException(E, str, nLogLv);
|
|
end;
|
|
|
|
class procedure ETgException.TraceException(Sender: TObject; E: Exception; nLogLv: Integer = 0);
|
|
begin
|
|
if Sender <> nil then
|
|
TTgTrace.T(Format('%s :: ETgException .. %s, Msg="%s"', [Sender.ClassName, E.ClassName, E.Message]), nLogLv)
|
|
else
|
|
TTgTrace.T(Format('Unknown Class :: ETgException .. %s - %s', [E.ClassName, E.Message]), nLogLv)
|
|
end;
|
|
|
|
class procedure ETgException.TraceException(Sender: TObject; E: Exception; const sInfo: String; nLogLv: Integer = 0);
|
|
begin
|
|
if Sender <> nil then
|
|
TTgTrace.T(Format('%s :: ETgException .. %s, Msg="%s" : Info = %s', [Sender.ClassName, E.ClassName, E.Message, sInfo]), nLogLv)
|
|
else
|
|
TTgTrace.T(Format('Unknown Class :: ETgException .. %s, Msg="%s" : Info = %s', [E.ClassName, E.Message, sInfo]), nLogLv);
|
|
end;
|
|
|
|
class procedure ETgException.TraceException(Sender: TObject; E: Exception; const sFormat: String; const Args: array of const; nLogLv: Integer = 0);
|
|
var
|
|
str: String;
|
|
begin
|
|
FmtStr(str, sFormat, Args);
|
|
TraceException(Sender, E, str, nLogLv);
|
|
end;
|
|
|
|
end.
|