Skip to content

Commit

Permalink
Merge pull request #137 from Tieske/customererror
Browse files Browse the repository at this point in the history
feat(error) allow custom error text on error messages
  • Loading branch information
EvandroLG authored Jan 24, 2024
2 parents fef1469 + b06c1bf commit 2b1d903
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pegasus/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b1d903

Please sign in to comment.