-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client option to log full reason for HTTP errors #319
base: dev
Are you sure you want to change the base?
Client option to log full reason for HTTP errors #319
Conversation
Going to wait on this one, but not deny it. |
Good enough for 2.x. I can always rewrite it in 3.0. I would rather have this as |
It'd be nice for debugging if a file & line number could be added to this, if that's easy to do. |
That is definitely doable with the help of the debug library, making use of |
Even if it's disabled by default like Sinister said? |
There will always be http errors you cannot avoid. But in the case it was Nonetheless, in my opinion this is something we can think of for Discordia 3. |
Done; 7d7f163
Agreed, but as @Bilal2453 mentioned, I think it would be best for it to be its own client option. |
I just realized this PR is for 3.0. Awkward. |
I honestly don't like the code. In particular: the concatenation before calling |
Understandable. Would adding something like this be better? function API:logWithMessage(level, res, method, url, message)
return self._client:log(level, '%i - %s : %s %s\n%s', res.code, res.reason, method, url, message)
end My worry is that this duplicates code. |
...or perhaps something like this? function API:log(level, res, method, url, extra)
local base = self._client:log(level, '%i - %s : %s %s', res.code, res.reason, method, url)
if extra ~= nil then
return base .. '\n' .. extra
else
return base
end
end |
This pull request adds a new
boolean
client optionlogFullErrors
(true
by default) which, whentrue
, makes theAPI
class log the full error reason (found inside the response body) of requests that return an error response. This makes debugging much easier as you're able to see exactly what went wrong without having to manually print the error message returned by Discordia methods.As an example, what before was:
now becomes: