Skip to content
Discussion options

You must be logged in to vote

Hey @chrs-b, thanks for bringing this up!

change_mapped_context

I can see the appeal, but I think this would actually go against a design choice in error-stack that's worth explaining.

change_context is designed so the new context comes from what the caller knows, not from what the lower error contains. The job layer knows "I was processing a job", the database layer knows "a query failed" — these are independent facts:

database.read_something(...)
    .change_context(JobError::ReadFailed)?;

Deriving JobError from DBError via something like change_mapped_context(|ctx| JobError::from(ctx)) is really a re-categorization, not adding context. If JobError can be mechanically derived from DBError

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by TimDiekmann
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants