From 6d50d836f538253e2d13d5ddb90495820f9cb259 Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Thu, 26 Apr 2018 11:19:25 -0400 Subject: MM-10232, MM-10259: Improve error handling from invalid json (#8668) * MM-10232: improve error handling from malformed slash command responses Switch to json.Unmarshal, which doesn't obscure JSON parse failures like json.Decode. The latter is primarily designed for streams of JSON, not necessarily unmarshalling just a single object. * rework HumanizedJsonError to expose Line and Character discretely * MM-10259: pinpoint line and character where json config error occurs * tweak HumanizeJsonError to accept err first --- model/client4.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 260d75df6..387ca038f 100644 --- a/model/client4.go +++ b/model/client4.go @@ -2991,7 +2991,9 @@ func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, * return nil, BuildErrorResponse(r, err) } else { defer closeBody(r) - return CommandResponseFromJson(r.Body), BuildResponse(r) + + response, _ := CommandResponseFromJson(r.Body) + return response, BuildResponse(r) } } @@ -3007,7 +3009,9 @@ func (c *Client4) ExecuteCommandWithTeam(channelId, teamId, command string) (*Co return nil, BuildErrorResponse(r, err) } else { defer closeBody(r) - return CommandResponseFromJson(r.Body), BuildResponse(r) + + response, _ := CommandResponseFromJson(r.Body) + return response, BuildResponse(r) } } -- cgit v1.2.3-1-g7c22