|
1 | 1 | //! Errors that might happen in the crate
|
2 | 2 |
|
3 |
| -#[derive(Debug, Fail)] |
| 3 | +use thiserror::Error; |
| 4 | + |
| 5 | +#[derive(Debug, Error)] |
4 | 6 | pub enum Error {
|
5 |
| - #[fail(display = "query is invalid: {}", error)] |
| 7 | + #[error("query is invalid: {error}")] |
6 | 8 | /// Error happens when a query is invalid
|
7 | 9 | InvalidQueryError { error: String },
|
8 | 10 |
|
9 |
| - #[fail(display = "Failed to build URL: {}", error)] |
| 11 | + #[error("Failed to build URL: {error}")] |
10 | 12 | /// Error happens when a query is invalid
|
11 | 13 | UrlConstructionError { error: String },
|
12 | 14 |
|
13 |
| - #[fail(display = "http protocol error: {}", error)] |
| 15 | + #[error("http protocol error: {error}")] |
14 | 16 | /// Error happens when a query is invalid
|
15 | 17 | ProtocolError { error: String },
|
16 | 18 |
|
17 |
| - #[fail(display = "http protocol error: {}", error)] |
| 19 | + #[error("http protocol error: {error}")] |
18 | 20 | /// Error happens when Serde cannot deserialize the response
|
19 | 21 | DeserializationError { error: String },
|
20 | 22 |
|
21 |
| - #[fail(display = "InfluxDB encountered the following error: {}", error)] |
| 23 | + #[error("InfluxDB encountered the following error: {error}")] |
22 | 24 | /// Error which has happened inside InfluxDB
|
23 | 25 | DatabaseError { error: String },
|
24 | 26 |
|
25 |
| - #[fail(display = "authentication error. No or incorrect credentials")] |
| 27 | + #[error("authentication error. No or incorrect credentials")] |
26 | 28 | /// Error happens when no or incorrect credentials are used. `HTTP 401 Unauthorized`
|
27 | 29 | AuthenticationError,
|
28 | 30 |
|
29 |
| - #[fail(display = "authorization error. User not authorized")] |
| 31 | + #[error("authorization error. User not authorized")] |
30 | 32 | /// Error happens when the supplied user is not authorized. `HTTP 403 Forbidden`
|
31 | 33 | AuthorizationError,
|
32 | 34 |
|
33 |
| - #[fail(display = "connection error: {}", error)] |
| 35 | + #[error("connection error: {error}")] |
34 | 36 | /// Error happens when reqwest fails
|
35 | 37 | ConnectionError {
|
36 |
| - #[fail(cause)] |
| 38 | + #[from] |
37 | 39 | error: reqwest::Error,
|
38 | 40 | },
|
39 | 41 | }
|
0 commit comments