Comments (3)
I ported some code from failure
. Some remarks:
- I was using tuple enum items, and I had to name the fields because the documentation didn't say whether they were supported or not
- It's not obvious that the
source
field is mandatory (fail
is nifty, though) - I'm somewhat worried about the size of the
Result
s. IIRC the compiler is bad at optimizing them, and sometimes it might be better to do an allocation instead. - I didn't look too much into it, but I'm not sure what
eager_context
is about
from snafu.
the documentation didn't say whether they were supported or not
They are not, but I’m open to discussion about it. I've opened #61 to talk about it.
I should also add this fact explicitly to the docs. You do get a specific error if you try to use tuple variants though.
the
source
field is mandatory
It is not; but if there’s no source
field you can’t use context
(where would the Result::Err
go?). Instead you just use ContextSelector { fields }.fail()
. Can you expand a bit more on wwhat you mean by "mandatory"?
- the size of the
Result
s
Do you mean Result
or the enum Error
type? I would expect that the size of the enum is max(size-of(variants)) + 1 byte + small amount padding)
if you have less than 256 variants. There is some discussion elsewhere about better supporting boxing source errors which might help a bit.
- what
eager_context
is about
TL;DR, context
is used with ?
and eager_context
is used without ?
.
from snafu.
It is not; but if there’s no source field you can’t use context (where would the Result::Err go?). Instead you just use ContextSelector { fields }.fail(). Can you expand a bit more on wwhat you mean by "mandatory"?
I don't have anything more to add to my comment in #10 (comment). Again, I don't mind the way it works, it's just an issue I ran into because I wasn't aware of fail()
.
Do you mean Result or the enum Error type?
The Error
enum, as the variants could presumably grow pretty large, depending on how many errors you're nesting.
from snafu.
Related Issues (20)
- alternate `Display` to include the source chain HOT 4
- Best way to consolidate error types HOT 9
- Investigate switching `IntoError` from an associated type to generics HOT 2
- Investigate adding `ResultExt::boxed` and `::boxed_local`
- Is it possible to automatically include fields in error's display? HOT 2
- Consider adding #[snafu(transparent)] HOT 6
- Support Serde for the built-in types HOT 6
- multiple error types (struct and enum) and generic `IntoError` HOT 2
- Simple context usage, mysterious compile error HOT 2
- Use the same deprecation macros on the no_std Error as the official Error HOT 3
- Add an ensure macro that works with pattern matching HOT 2
- Restore support for yeeting context selectors HOT 1
- Print multi-line errors on their own lines in `Report` HOT 2
- Const generics seem to be giving the derive macro trouble HOT 2
- question: Best practice for automatic error conversion over two module levels?
- Cannot use a generic with a whatever variant
- Incorrect year in changelog
- No apparent way to have an error enum variant documentation generated from a display string HOT 5
- Why isn't Whatever Send + Sync by default? HOT 5
- `Report` print doesn't prefix with "Error: " 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 snafu.