botahamec / exun Goto Github PK
View Code? Open in Web Editor NEWHandle unexpected errors
License: The Unlicense
Handle unexpected errors
License: The Unlicense
In the image crate, there's an error type that looks like this:
pub enum ImageError {
Decoding(DecodingError),
Encoding(EncodingError),
Parameter(ParameterError),
Limits(LimitError),
Unsupported(UnsupportedError),
IoError(std::io::Error),
}
I expect it possible to see a DecodingError
, but nothing else should be possible for my use. Perhaps we could find a way to make it easy to decode that. Here's the solution my project is using:
fn convert_image_decoding(e: image::ImageError) -> Expect<DecodingError> {
if let image::ImageError::Decoding(de) = e {
Expected(de.into())
} else {
Unexpected(e.into())
}
}
let texture = image::load_from_memory_with_format(buf, format.into()).map_err(convert_image_decoding)?;
The two constructors for RawUnexpected
are:
RawUnexpected::new
: takes an Error
RawUnexpected::msg
: takes a Display + Debug
I'm wondering if we'd like to change them to from_err
and from_msg
respectively, following the Rust API Guidelines. I used new
and msg
because that's what anyhow
and eyre
use.
An Option::unexpect
method would probably be useful.
I'd like to see serde
support in this crate. This would involve creating a new feature, which would be turned off by default. I can only see this being implemented for Exun
. I'm open to suggestions if someone can think of a way to make it work on RawUnexpected
or UnexpectedError
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.