Comments (8)
I've used failure
in a few projects now and it's pretty great. It feels similar to error-chain
but with a bit less magic. You could probably start using it now without changing much--just add #[derive(Fail)]
to your Error
enum as a start, and then you ought to be able to remove the std::error::Error
impl, and the From
impls. You might want to switch scroll
over first so that you get implicit conversion from its errors as well.
You can see a simple example of using failure
with a custom error type in this code I wrote:
https://github.com/luser/rust-disasm/blob/0758b8ac2820cd73137284423b7dfaf04c2701bd/src/lib.rs#L20
There are a few things there that are silly because the gimli
crates are using error-chain
, and interop between failure
and error-chain
is a little wonky. (boats has a PR open on error-chain with a fix, but it's a breaking change.)
In the meantime, the recommended workaround is to define a new trait that converts error-chain
errors, which isn't the best but it works. Here's an example of that:
https://github.com/luser/query-crates-index/blob/26a825fc11ac8d29b32bdf35a92748e3e31dedf4/src/main.rs#L30
You wind up writing whatever().sync()?
for things that return error-chain
errors, which is workable.
from goblin.
I think we wouldn't want to use failure::Error
in this crate, but instead #[derive(Failure)]
on a custom error enum.
from goblin.
silly because the gimli crates are using error-chain
Would love to get PRs to move to failure, btw.
from goblin.
I think we wouldn't want to use failure::Error in this crate, but instead #[derive(Failure)] on a custom error enum.
Yeah, that's what I was suggesting, just deriving Fail
on the existing Error
enum. That should immediately give you some niceties like auto-conversion from other error types, as well as easy error message formatting. (That being said, I'm not sure what the practical benefits of using your own error type vs. failure::Error
are, really. Just the ability to pattern-match specific errors, I guess?)
from goblin.
So with the new alloc
feature I think just adding derive annotation will work as expected and won't cause any problems in no_std
environments, would you agree @philipc ?
from goblin.
Yes, my understanding is that failure::Error
can't be used with no_std
, but derive is fine.
gimli crates are using error-chain
This was only in addr2line afaik, and that usage has been removed. Adding failure support to gimli would be good though.
from goblin.
Ok I think we should get the error story figured out. I'm leaning towards sticking with current error system, not pulling on another dep, as it's compatible with downstream users using failure.
from goblin.
Failure is unmaintained and deprecated now. https://github.com/rust-lang-nursery/failure
from goblin.
Related Issues (20)
- Failing to parse QEMU memory dump note .shstrtab HOT 2
- PE: handle empty import address table HOT 1
- COFF stringtable created with 'strings' function truncates the first 4 characters when used with symbol offset HOT 9
- Alternative owned data version? HOT 1
- Cannot parse loaded image due to rigidity around parsing Attribute Certificates
- Mach-O parser does not expose reserved section fields HOT 1
- Should strtab parsing jump over contigous blocks of `\0` HOT 3
- Malformed entity: Cannot map ImageDebugDirectory rva 0x3ac into offset HOT 2
- Help obtaining bytes of a function in .TEXT HOT 1
- Unable to parse ELF SectionHeader from raw bytes HOT 1
- Parsing relocations in a PE file HOT 3
- Little help with writing the modifications of an PE HOT 1
- Add Terse Executable (TE) support to goblin
- feature (PE): add rich header
- feature (PE): explicitly state presence or absence of support for various malformations
- Releasing a 0.8.1 ? HOT 1
- Version 0.8.1 includes a breaking change HOT 1
- Note::type_to_str is only valid when n_name is "GNU" HOT 1
- Parsing fails when the TLS index is in the zeroed area of a section HOT 3
- Parsing fails when a PE file has a TLS callback list which contains only the terminator
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 goblin.