Skip to content

error-stack: Putting data in the context struct vs. using attachments? #1818

Discussion options

You must be logged in to vote

Hello, I am sorry for taking so long to respond to your question! I completely missed this thread. My bad 😅

Your question is entirely valid, and thanks for asking. I think "blank" structs with no information and your use-case go hand in hand, but there are some use cases where attachments are beneficial. They are primarily useful in cases where either A) things might change, B) information is unknown during the creation of the context, C) information is shared across multiple errors

I am working on an experimental deserialization library (deer), which heavily uses error-stack. To illustrate the use cases outlined I'll take some snippets of the code

A) Things might change

Let's say we want…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AriaFallah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/libs > error-stack Affects the `error-stack` crate (library) area/libs Relates to first-party libraries/crates/packages (area)
2 participants