mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:26:24 +02:00
CreateJSON2ErrorResponse now clones ID parameter instead of consuming it (bug ID 35999)
git-svn-id: trunk@42783 -
This commit is contained in:
parent
dc3b9b4ab0
commit
778ae03532
@ -412,7 +412,9 @@ function CreateJSON2ErrorResponse(Const AMessage : String; Const ACode : Integer
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
If (ID=Nil) then
|
If (ID=Nil) then
|
||||||
ID:=TJSONNull.Create;
|
ID:=TJSONNull.Create
|
||||||
|
else
|
||||||
|
ID:=ID.Clone;
|
||||||
Result:=TJSONErrorObject.Create(['jsonrpc','2.0','error',CreateJSONErrorObject(AMessage,ACode),idname,ID]);
|
Result:=TJSONErrorObject.Create(['jsonrpc','2.0','error',CreateJSONErrorObject(AMessage,ACode),idname,ID]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -420,7 +422,9 @@ function CreateJSON2ErrorResponse(Const AFormat : String; Args : Array of const;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
If (ID=Nil) then
|
If (ID=Nil) then
|
||||||
ID:=TJSONNull.Create;
|
ID:=TJSONNull.Create
|
||||||
|
else
|
||||||
|
ID:=ID.Clone;
|
||||||
Result:=TJSONErrorObject.Create(['jsonrpc','2.0','error',CreateJSONErrorObject(Format(AFormat,Args),ACode),idname,ID]);
|
Result:=TJSONErrorObject.Create(['jsonrpc','2.0','error',CreateJSONErrorObject(Format(AFormat,Args),ACode),idname,ID]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -812,7 +816,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
// No response, and a response was expected.
|
// No response, and a response was expected.
|
||||||
if (ID<>Nil) or not (jdoNotifications in Options) then
|
if (ID<>Nil) or not (jdoNotifications in Options) then
|
||||||
Result:=CreateJSON2Error(SErrNoResponse,[M],EJSONRPCInternalError,ID.Clone,transactionProperty);
|
Result:=CreateJSON2Error(SErrNoResponse,[M],EJSONRPCInternalError,ID,transactionProperty);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -832,7 +836,7 @@ begin
|
|||||||
If (Result<>Nil) then
|
If (Result<>Nil) then
|
||||||
FreeAndNil(Result);
|
FreeAndNil(Result);
|
||||||
If Assigned(ID) and not (ID is TJSONNull) then
|
If Assigned(ID) and not (ID is TJSONNull) then
|
||||||
Result:=CreateJSON2Error(E.Message,EJSONRPCInternalError,ID.Clone,transactionproperty)
|
Result:=CreateJSON2Error(E.Message,EJSONRPCInternalError,ID,transactionproperty)
|
||||||
else
|
else
|
||||||
Result:=CreateJSON2Error(E.Message,EJSONRPCInternalError,Nil,transactionproperty);
|
Result:=CreateJSON2Error(E.Message,EJSONRPCInternalError,Nil,transactionproperty);
|
||||||
end;
|
end;
|
||||||
@ -973,7 +977,7 @@ begin
|
|||||||
O:=A.Objects[i];
|
O:=A.Objects[i];
|
||||||
J:=O.IndexOfName('id');
|
J:=O.IndexOfName('id');
|
||||||
if (J<>-1) then
|
if (J<>-1) then
|
||||||
ID:=O.Items[J].Clone;
|
ID:=O.Items[J];
|
||||||
end;
|
end;
|
||||||
TJSONArray(Result).Add(CreateJSON2ErrorResponse(SErrJSON2NotAllowed,EJSONRPCInvalidRequest,ID,transactionproperty));
|
TJSONArray(Result).Add(CreateJSON2ErrorResponse(SErrJSON2NotAllowed,EJSONRPCInvalidRequest,ID,transactionproperty));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user