Skip to content

Improve RestException logging#127

Merged
KubaZ2 merged 1 commit into
alphafrom
feature/improve-rest-exception-logging
Jun 13, 2025
Merged

Improve RestException logging#127
KubaZ2 merged 1 commit into
alphafrom
feature/improve-rest-exception-logging

Conversation

@KubaZ2

@KubaZ2 KubaZ2 commented Jun 13, 2025

Copy link
Copy Markdown
Member

No description provided.

@KubaZ2 KubaZ2 requested a review from Copilot June 13, 2025 22:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances logging for REST exceptions by overriding ToString() methods and updating test exception handling to leverage the new formatting.

  • Added a performant ToString() override to RestException to include error details and stack trace.
  • Sealed RestError and added a ToString() override to serialize itself.
  • Updated tests to catch and log exceptions via Exception.ToString() rather than manually serializing RestError.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Tests/NetCord.Test/Program.cs Changed catch from RestException to Exception and replaced manual JSON logging.
NetCord/Rest/RestException.cs Implemented a custom ToString() with string.Create for structured exception info.
NetCord/Rest/RestError.cs Marked RestError as sealed and added a ToString() override for JSON output.
Comments suppressed due to low confidence (1)

Tests/NetCord.Test/Program.cs:150

  • Catching all exceptions here can mask unrelated errors; consider catching RestException specifically so that other exceptions bubble up properly.
catch (Exception ex)


public RestError? Error { get; }

public override string ToString()

Copilot AI Jun 13, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This manual span-based construction is performant but complex; consider adding a comment or using a simpler StringBuilder approach if performance is not critical to improve readability and future maintenance.

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

The documentation preview is available at https://preview.netcord.dev/127.

@KubaZ2 KubaZ2 merged commit aeecfe0 into alpha Jun 13, 2025
1 check passed
@KubaZ2 KubaZ2 deleted the feature/improve-rest-exception-logging branch June 13, 2025 22:31
@KubaZ2 KubaZ2 mentioned this pull request Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants