https://github.com/tailhook/quick-error
A rust-macro which makes errors easy to write
https://github.com/tailhook/quick-error
conversion error macro reporting rust
Last synced: 8 months ago
JSON representation
A rust-macro which makes errors easy to write
- Host: GitHub
- URL: https://github.com/tailhook/quick-error
- Owner: tailhook
- License: apache-2.0
- Created: 2015-09-09T22:34:39.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-04-21T19:00:18.000Z (over 1 year ago)
- Last Synced: 2025-05-03T00:05:19.741Z (8 months ago)
- Topics: conversion, error, macro, reporting, rust
- Language: Rust
- Size: 638 KB
- Stars: 334
- Watchers: 8
- Forks: 35
- Open Issues: 19
-
Metadata Files:
- Readme: README.rst
- License: LICENSE-APACHE
Awesome Lists containing this project
README
===========
Quick Error
===========
:Status: production-ready
:Documentation: https://docs.rs/quick-error/
A macro which makes error types pleasant to write.
Features:
* Define enum type with arbitrary parameters
* Concise notation of ``Display`` and ``Error`` traits
* Full control of ``Display`` and ``Error`` trait implementation
* Any number of ``From`` traits
* Support for all enum-variants ``Unit``, ``Tuple`` and ``Struct``
Here is the comprehensive example:
.. code-block:: rust
quick_error! {
#[derive(Debug)]
pub enum IoWrapper {
Io(err: io::Error) {
from()
display("I/O error: {}", err)
source(err)
}
Other(descr: &'static str) {
display("Error {}", descr)
}
IoAt { place: &'static str, err: io::Error } {
source(err)
display(me) -> ("io error at {}: {}", place, err)
from(s: String) -> {
place: "some string",
err: io::Error::new(io::ErrorKind::Other, s)
}
}
Discard {
from(&'static str)
}
}
}
=======
License
=======
Licensed under either of
* Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
------------
Contribution
------------
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.