Skip to content

serde: record errors as a struct with fields for sources#91

Merged
hawkw merged 1 commit into
eliza/fix-errorfrom
eliza/complicated-error
Mar 8, 2022
Merged

serde: record errors as a struct with fields for sources#91
hawkw merged 1 commit into
eliza/fix-errorfrom
eliza/complicated-error

Conversation

@hawkw
Copy link
Copy Markdown
Member

@hawkw hawkw commented Mar 7, 2022

Depends on #89

This PR changes valuable-serde's recording of dyn Error values to
record the error as a serde struct with message and source fields.
This way, we can serialize errors with source chains more nicely.

When the backtrace support for std::error::Error is stable, we could
also record backtraces as a field. We could even consider adding a build
script to detect the nightly compiler and conditionally enable a cfg
for backtrace support, but that seems better left to a follow-up.

This PR changes `valuable-serde`'s recording of `dyn Error` values to
record the error as a `serde` struct with `message` and `source` fields.
This way, we can serialize errors with source chains more nicely.

When the backtrace support for `std::error::Error` is stable, we could
also record backtraces as a field. We could even consider adding a build
script to detect the nightly compiler and conditionally enable a `cfg`
for backtrace support, but that seems better left to a follow-up.
@hawkw hawkw requested a review from taiki-e March 7, 2022 17:59
Copy link
Copy Markdown
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me

@hawkw hawkw merged commit 5624fe1 into eliza/fix-error Mar 8, 2022
@taiki-e taiki-e deleted the eliza/complicated-error branch March 9, 2022 03:21
@taiki-e taiki-e restored the eliza/complicated-error branch March 10, 2022 14:12
@taiki-e
Copy link
Copy Markdown
Member

taiki-e commented Mar 10, 2022

Hmm. It looks like this was merged into #89 after #89 was merged into master.

@hawkw
Copy link
Copy Markdown
Member Author

hawkw commented Mar 10, 2022

Hmm. It looks like this was merged into #89 after #89 was merged into master.

Whoops...normally, I thought GitHub rebases branches onto master when the base branch merges, so I expected that to happen here...

@hawkw
Copy link
Copy Markdown
Member Author

hawkw commented Mar 10, 2022

@taiki-e opened #92 with the correct base branch, sorry about that!

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