Skip to content

Commit 2996140

Browse files
Merge pull request #17 from antoniojmsjr/master
Melhorias na geração do JSON da classe EHorseException
2 parents d8bdaef + c2186f9 commit 2996140

File tree

1 file changed

+1
-18
lines changed

1 file changed

+1
-18
lines changed

Src/Horse.HandleException.pas

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,7 @@ procedure HandleException(Req: THorseRequest; Res: THorseResponse; Next: {$IF DE
4242
raise;
4343
on E: EHorseException do
4444
begin
45-
LJSON := TJSONObject.Create;
46-
LJSON.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}('error', E.Error);
47-
if not E.Title.Trim.IsEmpty then
48-
begin
49-
LJSON.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}('title', E.Title);
50-
end;
51-
if not E.&Unit.Trim.IsEmpty then
52-
begin
53-
LJSON.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}('unit', E.&Unit);
54-
end;
55-
if E.Code <> 0 then
56-
begin
57-
LJSON.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}('code', {$IF DEFINED(FPC)}TJSONIntegerNumber{$ELSE}TJSONNumber{$ENDIF}.Create(E.Code));
58-
end;
59-
if E.&Type <> TMessageType.Default then
60-
begin
61-
LJSON.{$IF DEFINED(FPC)}Add{$ELSE}AddPair{$ENDIF}('type', GetEnumName(TypeInfo(TMessageType), Integer(E.&Type)));
62-
end;
45+
LJSON := TJSONObject.ParseJSONValue(E.ToJSON) as TJSONObject;
6346
SendError(Res, LJSON, Integer(E.Status));
6447
end;
6548
on E: Exception do

0 commit comments

Comments
 (0)