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

Improving server exception logging by including exception in log message #471

Merged
merged 17 commits into from
Apr 12, 2024

Conversation

valbers
Copy link
Collaborator

@valbers valbers commented Apr 5, 2024

There were two problems before:

  1. The error message itself was not being logged, but only a mention that there was an error;
  2. It was not possible to access the possibly original exception which led to the request processing error. However, it's extremely useful to log the error with the whole exception information including the stack trace of where the exception was thrown.

Before

before-srv-ex-logging

After

after-srv-ex-logging

However, these changes also introduce a breaking change as GQLProblemDetails now has an additional member holding the possible exception which generated the error.

GQLProblemDetails is public and could be in use by code using FSharp.Data.GraphQL.

valbers added 2 commits April 5, 2024 18:03
…n info too

  There were two problems before:
    1. The error message itself was not being logged, but only a mention
       that there was an error;
    2. It was not possible to access the possibly original exception
       which led to the request processing error. However, it's
       extremely useful to log the error with the whole exception
       information including the stack trace of where the exception was thrown.
  However, these changes also introduce a breaking change as IGQLError
and GQLProblemDetails now each have an additional mandatory member
holding the possible exception which generated the error.
  These types (especiall GQLProblemDetails) are public and could be used
by code using FSharp.Data.GraphQL.
@valbers valbers requested review from xperiandri and ivelten April 5, 2024 16:22
src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
src/FSharp.Data.GraphQL.Shared/SchemaDefinitions.fs Outdated Show resolved Hide resolved
tests/FSharp.Data.GraphQL.Tests/AstValidationTests.fs Outdated Show resolved Hide resolved
valbers added 5 commits April 8, 2024 22:07
…info too

  Note: this commit is a 2nd attempt after getting feedback from code
review.

  There were two problems before:
    1. The error message itself was not being logged, but only a mention
       that there was an error;
    2. It was not possible to access the possibly original exception
       which led to the request processing error. However, it's
       extremely useful to log the error with the whole exception
       information including the stack trace of where the exception was thrown.
  However, these changes also introduce a breaking change as IGQLError
and GQLProblemDetails now each have an additional mandatory member
holding the possible exception which generated the error.
  These types (especiall GQLProblemDetails) are public and could be used
by code using FSharp.Data.GraphQL.
@valbers
Copy link
Collaborator Author

valbers commented Apr 9, 2024

@xperiandri I rewrote my changes according to your suggestion regarding the extra interface. Please kindly review the current changes.

Copy link
Collaborator

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

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

Just one suggestion

@valbers
Copy link
Collaborator Author

valbers commented Apr 10, 2024

@xperiandri there's a commit for applying fantomas formatting to HttpHandlers.fs but I find it suspicious. Do you have an idea why the formatting is so different now?

Copy link
Collaborator

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

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

@valbers it is something bad on your side. I've just formatted it on my side and it is similar to what it was before your formatting.
Try restore the latest Fantomas with tool restore in this repo

src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
@valbers valbers enabled auto-merge (squash) April 11, 2024 19:11
@valbers
Copy link
Collaborator Author

valbers commented Apr 11, 2024

@xperiandri waiting for your approving review.

Copy link
Collaborator

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

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

What do you think?

src/FSharp.Data.GraphQL.Shared/Errors.fs Outdated Show resolved Hide resolved
Copy link
Collaborator

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

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

One last thing 🙂

  Co-authored-by: Andrii Chebukin <XperiAndri@Outlook.com>
@valbers valbers merged commit ac6eae9 into fsprojects:dev Apr 12, 2024
3 checks passed
@xperiandri
Copy link
Collaborator

Cool! Lots of thanks for the contribution!

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.

3 participants