From 57d5610a581e618107d71cc152af31204ba17f5b Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Thu, 19 Dec 2019 14:41:57 -0800 Subject: [PATCH] plugin: Improve HTTP error messages by using response body --- plugin/src/ApiContext.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin/src/ApiContext.lua b/plugin/src/ApiContext.lua index d1c2feed..6e5b36e0 100644 --- a/plugin/src/ApiContext.lua +++ b/plugin/src/ApiContext.lua @@ -19,8 +19,9 @@ end local function rejectFailedRequests(response) if response.code >= 400 then - -- TODO: Nicer error types for responses, using response JSON if valid. - return Promise.reject(tostring(response.code)) + local message = string.format("HTTP %s:\n%s", tostring(response.code), response.body) + + return Promise.reject(message) end return response