Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to thiserror from failure #101

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ maintenance = { status = "actively-developed" }
[dependencies]
bitflags = "1"
libc = "0.2"
failure = "0.1"
thiserror = "1.0.20"
ui-sys = { path = "../ui-sys", version = "0.2.1" }
regex = "1"
lazy_static = "1"
Expand Down
14 changes: 4 additions & 10 deletions iui/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
//! Error types for this crate.

/// The error type returned by functions in this crate which might fail.
#[derive(Fail, Debug)]
#[derive(thiserror::Error, Debug)]
pub enum UIError {
/// Signifies that the underlying library was unable to properly hook into the platform's GUI APIs.
#[fail(
display = "unable to initialize the underlying system bindings: {}",
error
)]
#[error("unable to initialize the underlying system bindings: {error}")]
FailedInitError { error: String },
/// Signifies that an attempt was made to initialize a new instance of the underlying library while
/// one already existed.
#[fail(display = "cannot initialize multiple instances of the libui toolkit")]
#[error("cannot initialize multiple instances of the libui toolkit")]
MultipleInitError(),
/// Signifies that an attempt was made to remove a tab from a tab group that was out of bounds.
#[fail(
display = "cannot remove index {} from tab group: there are only {} tabs in the group",
index, n
)]
#[error("cannot remove index {index} from tab group: there are only {n} tabs in the group")]
TabGroupIndexOutOfBounds { index: i32, n: i32 },
}
3 changes: 1 addition & 2 deletions iui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate failure;
extern crate thiserror;
#[macro_use]
extern crate lazy_static;
extern crate libc;
Expand Down