Skip to content

Commit 8573298

Browse files
Merge pull request #3 from slipkbode/master
Ajuste nos métodos para atender a classe EHorseExcpetion que foi alte…
2 parents acb2242 + 75afa66 commit 8573298

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Src/Horse.HandleException.pas

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ procedure HandleException(Req: THorseRequest; Res: THorseResponse; Next: TProc);
88

99
implementation
1010

11-
uses System.JSON;
11+
uses System.JSON, System.TypInfo;
1212

1313
procedure HandleException(Req: THorseRequest; Res: THorseResponse; Next: TProc);
1414
var
@@ -24,6 +24,24 @@ procedure HandleException(Req: THorseRequest; Res: THorseResponse; Next: TProc);
2424
begin
2525
LJSON := TJSONObject.Create;
2626
LJSON.AddPair('error', E.Error);
27+
28+
if not E.Title.Trim.IsEmpty then
29+
begin
30+
LJSON.AddPair('title', E.Title);
31+
end;
32+
33+
if not E.&Unit.Trim.IsEmpty then
34+
begin
35+
LJSON.AddPair('unit', E.&Unit);
36+
end;
37+
38+
if E.Code <> 0 then
39+
begin
40+
LJSON.AddPair('code', TJSONNumber.Create(E.Code));
41+
end;
42+
43+
LJSON.AddPair('type', GetEnumName(TypeInfo(TMessageType), Integer(E.&Type)));
44+
2745
Res.Send<TJSONObject>(LJSON).Status(E.Status);
2846
end;
2947

0 commit comments

Comments
 (0)