Skip to content
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

Add failure logging to DiscordWebhook.cs #30835

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

cranberriez
Copy link
Contributor

@cranberriez cranberriez commented Aug 9, 2024

About the PR

Add a new function that logs errors with discord webhook's http requests.

Why / Balance

Added as a response to issue #30248. Also created for a Open Source Software course, any review is appreciated but this does not need to be accepted.

Technical details

Create, Delete, and Edit functions were modified slightly to call the log function but return the same information as before.

The log function logs the error code, caller method using a simple constant (could be better), and attempts to log headers mentioned in issue #30248.

Media

Nothing of note.

Requirements

  • I have read and I am following the Pull Request Guidelines. I understand that not doing so may get my pr closed at maintainer’s discretion
  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

No obvious breaking changes. Testing was not as extensive as I would have liked.

Changelog

🆑

  • tweak: Added Discord webhook error logging!

Add a new function that logs errors with discord webhook's http requests.

Create, Delete, and Edit functions were modified slightly to call the log function but return the same information as before.

The log function logs the error code, caller method using a simple constant (could be better), and attempts to log headers mentioned in issue space-wizards#30248.
Comment on lines 127 to 136

if (response.Headers.TryGetValues("Retry-After", out var retryAfter))
_sawmill.Error($"Retry-After: {string.Join(", ", retryAfter)}");

if (response.Headers.TryGetValues("X-RateLimit-Global", out var globalRateLimit))
_sawmill.Error($"X-RateLimit-Global: {string.Join(", ", globalRateLimit)}");

if (response.Headers.TryGetValues("X-RateLimit-Scope", out var rateLimitScope))
_sawmill.Error($"X-RateLimit-Scope: {string.Join(", ", rateLimitScope)}");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on logging these, I think the default one is fine.

@metalgearsloth metalgearsloth added the S: Awaiting Changes Status: Changes are required before another review can happen label Aug 14, 2024
@PJB3005 PJB3005 merged commit beb86fa into space-wizards:master Aug 20, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: Awaiting Changes Status: Changes are required before another review can happen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants