Skip to content

Commit 7c999e5

Browse files
Created a basic Error type
1 parent 18669e6 commit 7c999e5

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ edition = "2018"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10+
thiserror = "1.0.24"

src/error.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use thiserror::Error;
2+
3+
#[derive(Error, Debug)]
4+
pub enum TypesenseError {
5+
/// Config error.
6+
#[error("config error")]
7+
ConfigError,
8+
9+
/// Timeout.
10+
#[error("timeout")]
11+
Timeout,
12+
13+
/// Request malformed.
14+
#[error("request malformed")]
15+
RequestMalformed,
16+
17+
/// Request unauthorized.
18+
#[error("request unauthorized")]
19+
RequestUnauthorized,
20+
21+
/// Request forbidden.
22+
#[error("request forbidden")]
23+
RequestForbidden,
24+
25+
/// Object not found.
26+
#[error("object not found")]
27+
ObjectNotFound,
28+
29+
/// Object already exists.
30+
#[error("object already exists")]
31+
ObjectAlreadyExists,
32+
33+
/// Object unprocessable.
34+
#[error("object unprocessable")]
35+
ObjectUnprocessable,
36+
37+
/// Server error.
38+
#[error("server error")]
39+
ServerError,
40+
41+
/// Service unavailable.
42+
#[error("service unavailable")]
43+
ServiceUnavailable,
44+
45+
/// HTTP status error.
46+
#[error("HTTP status error")]
47+
HTTPStatusError,
48+
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
//! # Typesense
33
//!
44
//! Welcome to typesense, the rust library for the Typesense API.
5+
6+
mod error;

0 commit comments

Comments
 (0)