diff --git a/influxdb/Cargo.toml b/influxdb/Cargo.toml index f0c9bfd..cdb989c 100644 --- a/influxdb/Cargo.toml +++ b/influxdb/Cargo.toml @@ -16,15 +16,15 @@ repository = "https://github.com/Empty2k12/influxdb-rust" travis-ci = { repository = "Empty2k12/influxdb-rust", branch = "master" } [dependencies] -chrono = { version = "0.4.11", features = ["serde"] } -failure = "0.1.7" +chrono = { version = "0.4.11", features = ["serde"] } futures = "0.3.4" +lazy_static = "1.4.0" influxdb_derive = { version = "0.1.0", optional = true } +regex = "1.3.5" reqwest = { version = "0.10.4", features = ["json"] } serde = { version = "1.0.104", features = ["derive"], optional = true } serde_json = { version = "1.0.48", optional = true } -regex = "1.3.5" -lazy_static = "1.4.0" +thiserror = "1.0" [features] use-serde = ["serde", "serde_json"] diff --git a/influxdb/src/client/mod.rs b/influxdb/src/client/mod.rs index 6afb127..eca7c10 100644 --- a/influxdb/src/client/mod.rs +++ b/influxdb/src/client/mod.rs @@ -166,7 +166,7 @@ impl Client { /// use std::time::{SystemTime, UNIX_EPOCH}; /// /// # #[tokio::main] - /// # async fn main() -> Result<(), failure::Error> { + /// # async fn main() -> Result<(), influxdb::Error> { /// let start = SystemTime::now(); /// let since_the_epoch = start /// .duration_since(UNIX_EPOCH) diff --git a/influxdb/src/error.rs b/influxdb/src/error.rs index 6a452d5..b14d44b 100644 --- a/influxdb/src/error.rs +++ b/influxdb/src/error.rs @@ -1,39 +1,41 @@ //! Errors that might happen in the crate -#[derive(Debug, Fail)] +use thiserror::Error; + +#[derive(Debug, Error)] pub enum Error { - #[fail(display = "query is invalid: {}", error)] + #[error("query is invalid: {error}")] /// Error happens when a query is invalid InvalidQueryError { error: String }, - #[fail(display = "Failed to build URL: {}", error)] + #[error("Failed to build URL: {error}")] /// Error happens when a query is invalid UrlConstructionError { error: String }, - #[fail(display = "http protocol error: {}", error)] + #[error("http protocol error: {error}")] /// Error happens when a query is invalid ProtocolError { error: String }, - #[fail(display = "http protocol error: {}", error)] + #[error("http protocol error: {error}")] /// Error happens when Serde cannot deserialize the response DeserializationError { error: String }, - #[fail(display = "InfluxDB encountered the following error: {}", error)] + #[error("InfluxDB encountered the following error: {error}")] /// Error which has happened inside InfluxDB DatabaseError { error: String }, - #[fail(display = "authentication error. No or incorrect credentials")] + #[error("authentication error. No or incorrect credentials")] /// Error happens when no or incorrect credentials are used. `HTTP 401 Unauthorized` AuthenticationError, - #[fail(display = "authorization error. User not authorized")] + #[error("authorization error. User not authorized")] /// Error happens when the supplied user is not authorized. `HTTP 403 Forbidden` AuthorizationError, - #[fail(display = "connection error: {}", error)] + #[error("connection error: {error}")] /// Error happens when reqwest fails ConnectionError { - #[fail(cause)] + #[from] error: reqwest::Error, }, } diff --git a/influxdb/src/integrations/serde_integration/mod.rs b/influxdb/src/integrations/serde_integration/mod.rs index 91dddde..9c66c63 100644 --- a/influxdb/src/integrations/serde_integration/mod.rs +++ b/influxdb/src/integrations/serde_integration/mod.rs @@ -23,7 +23,7 @@ //! } //! //! # #[tokio::main] -//! # async fn main() -> Result<(), failure::Error> { +//! # async fn main() -> Result<(), influxdb::Error> { //! let client = Client::new("http://localhost:8086", "test"); //! let query = Query::raw_read_query( //! "SELECT temperature FROM /weather_[a-z]*$/ WHERE time > now() - 1m ORDER BY DESC", diff --git a/influxdb/src/lib.rs b/influxdb/src/lib.rs index b6d7219..41450eb 100644 --- a/influxdb/src/lib.rs +++ b/influxdb/src/lib.rs @@ -73,9 +73,6 @@ #![allow(clippy::needless_doctest_main)] -#[macro_use] -extern crate failure; - mod client; mod error; mod query;