diff --git a/crates/iota-sdk-graphql-client/Cargo.toml b/crates/iota-sdk-graphql-client/Cargo.toml
index b79b2520d..ff058b223 100644
--- a/crates/iota-sdk-graphql-client/Cargo.toml
+++ b/crates/iota-sdk-graphql-client/Cargo.toml
@@ -14,12 +14,12 @@ bcs.workspace = true
chrono = "0.4.26"
cynic.workspace = true
derive_more = { workspace = true, features = ["from"] }
-eyre.workspace = true
futures.workspace = true
reqwest = { workspace = true, default-features = false, features = ["rustls-tls", "json"] }
serde.workspace = true
serde_json.workspace = true
strum = { workspace = true, features = ["derive"] }
+thiserror.workspace = true
tokio = { workspace = true, features = ["time"] }
tracing = "0.1.37"
url = "2.5.3"
@@ -30,6 +30,7 @@ iota-types = { workspace = true, features = ["serde", "hash"] }
getrandom = { version = "0.2", features = ["js"] }
[dev-dependencies]
+eyre.workspace = true
rand.workspace = true
iota-types = { workspace = true, features = ["serde", "rand", "hash"] }
diff --git a/crates/iota-sdk-graphql-client/src/faucet.rs b/crates/iota-sdk-graphql-client/src/faucet.rs
index dc7f6c54c..bc475510e 100644
--- a/crates/iota-sdk-graphql-client/src/faucet.rs
+++ b/crates/iota-sdk-graphql-client/src/faucet.rs
@@ -4,7 +4,6 @@
use std::time::Duration;
-use eyre::{bail, eyre};
use iota_types::{Address, Digest, ObjectId};
use reqwest::{StatusCode, Url};
use serde::{Deserialize, Serialize};
@@ -18,6 +17,26 @@ pub const FAUCET_LOCAL_HOST: &str = "http://localhost:9123";
const FAUCET_REQUEST_TIMEOUT: Duration = Duration::from_secs(120);
const FAUCET_POLL_INTERVAL: Duration = Duration::from_secs(2);
+#[derive(thiserror::Error, Debug)]
+pub enum FaucetError {
+ #[error("Cannot fetch request status due to a bad gateway.")]
+ BadGateway,
+ #[error("Faucet request was unsuccessful: {0}")]
+ Request(String),
+ #[error("Reqwest error: {0}")]
+ Reqwest(#[from] reqwest::Error),
+ #[error("Faucet request was unsuccessful: {0}")]
+ StatusCode(StatusCode),
+ #[error("Faucet request timed out")]
+ TimedOut,
+ #[error(
+ "Faucet service received too many requests from this IP address. Please try again after 60 minutes."
+ )]
+ TooManyRequests,
+ #[error("Faucet service is currently overloaded or unavailable. Please try again later.")]
+ Unavailable,
+}
+
pub struct FaucetClient {
faucet_url: Url,
inner: reqwest::Client,
@@ -95,13 +114,13 @@ impl FaucetClient {
/// Request gas from the faucet. Note that this will return the UUID of the
/// request and not wait until the token is received. Use
/// `request_and_wait` to wait for the token.
- pub async fn request(&self, address: Address) -> eyre::Result