From b06c1bfe99b6735e0610cb1780c15f70c076cbf4 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Fri, 3 Mar 2023 20:06:14 +0100 Subject: [PATCH] feat(error) allow custom error text on error messages --- src/pegasus/response.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pegasus/response.lua b/src/pegasus/response.lua index e38de52..f9e8297 100644 --- a/src/pegasus/response.lua +++ b/src/pegasus/response.lua @@ -142,10 +142,10 @@ function Response:_getHeaders() return table.concat(headers) end -function Response:writeDefaultErrorMessage(statusCode) +function Response:writeDefaultErrorMessage(statusCode, errMessage) self:statusCode(statusCode) local content = string.gsub(DEFAULT_ERROR_MESSAGE, '{{ STATUS_CODE }}', statusCode) - self:write(string.gsub(content, '{{ STATUS_TEXT }}', STATUS_TEXT[statusCode]), false) + self:write(string.gsub(content, '{{ STATUS_TEXT }}', errMessage or STATUS_TEXT[statusCode]), false) return self end