Comments (2)
Hi @Tohman21 and thanks for filing the issue.
TL;DR: This is blocked by the specialization
feature.
I'd love to implement Error
for Report
but currently that's sadly not possible for a few reasons:
- (major) With an upcoming change we remove
IntoReport
, which impliesimpl<T, C: Context> ResultExt for Result<T, C>
. ImplementingError
forReport
would imply a conflicting implementation. It's likely, that this can be solved withfeature(specialization)
enabled, but I have not tested this, yet. If this would be a breaking change this is fine as we want to adjust other parts of the API as soon asspecialization
is possible (e.g. mergingattach
andattach_printable
). - (major) If
Error
is implemented onReport
it's expected thatError::source
is behaving correctly. Aserror-stack
supports multiple source errors, the mapping does not work correctly. We're planning some overhaul for this "related-errors" feature in the near future and I will definitely will keep this issue in mind. - (probably the hardest issue to solve) It's easily possible to create
Report<Report<E>>
, which results in unexpected behavior, annoying errors, and hard-to-debug issues. It's simply not what people want to use. This cannot easily be solved without some kind of negative trait bounds which, AFAIK, is nothing that is immediately planned right now. Possibly it's possible to solve this viaspecialization
, though. - (minor) There is a conflicting implementation between the
From
conversion ofReport<E>
andBox<dyn Error>
whenError
is implemented forReport<E>
, but if anything like this is going to be added, we'd probably implementContext
forReport<E: 'static>
instead to be more generic. This is probably not a big issue but another annoyance when dealing with theError
trait. Ultimately we probably going to remove theContext
trait whencore::error::Error
is stabilized but that's not fully decided yet asContext
is potentially more generic thanError
semantically.
One other possible route would also be to not remove IntoReport
, yet, but rather try to implement Error
on Report
earlier (I don't expect specialization
to be stabilized soon), but we still need to figure out the other issues first. However, with IntoReport
and Report<E>: Error
creating Report<Report<E>>
is very easy by calling Result<T, Report<E>>::into_report()
. We even have a dedicated test case to forbid this:
hash/libs/error-stack/tests/ui/into_report.rs
Lines 19 to 24 in 12fecc4
it's possible that one of the listed issues is not really an issue or that I forgot something but it's definitely not easily possible now - and I'm very sad about this! We'd be very happy to hear more thoughts about this as well!
Happy to hear some thoughts from @indietyp as well.
from hash.
Thanks for quick answer. Yep, the problem is deeper than I thought
from hash.
Related Issues (20)
- GEN-68: `.into_report()` doesn't include error source chains HOT 9
- H-1: Support loading blocks in # Storybook
- [H-2] Make headings in hash.dev blog posts anchor-linkable HOT 1
- H-3: Add all HASH blocks to # Storybook
- [H-4] Add blurhash to hash.dev slide component HOT 1
- H-5: Automate publishing of new/updated HASH blocks to the block gallery & # Storybook
- H-7: Update hash.dev styles to match those in Figma HOT 2
- error[E0554]: `#![feature]` may not be used on the stable release channel HOT 10
- error[E0658]: use of unstable library feature 'lazy_cell' HOT 2
- [H-12] Change title of hash.dev/blog/[post] pages HOT 1
- [H-13] hash.dev: appropriately comma separate author names when articles have 3 or more HOT 1
- hCloud Error when running experiment for Python Model - Using Pandas library HOT 1
- Action Required: Fix Renovate Configuration HOT 2
- 🚀 Dependency Updates
- `IntoReport` is deprecated, but `ReportExt` that replaces it is not in `error-stack` HOT 2
- GEN-108(issue): Show some minimal but working example on the main documentation page HOT 7
- GEN-115: Way to disable error location and/or backtrace HOT 4
- Support generation of Context Implementation on a type with derive macro HOT 1
- GEN-132: Unclear initial examples in the docs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hash.