diff --git a/ethers-etherscan/src/errors.rs b/ethers-etherscan/src/errors.rs index f10920ba..f6cc587d 100644 --- a/ethers-etherscan/src/errors.rs +++ b/ethers-etherscan/src/errors.rs @@ -41,6 +41,8 @@ pub enum EtherscanError { BlockedByCloudflare, #[error("The Requested prompted a cloudflare captcha security challenge to review the security of your connection before proceeding.")] CloudFlareSecurityChallenge, + #[error("Received `Page not found` response. API server is likely down")] + PageNotFound, } /// etherscan/polyscan is protected by cloudflare, which can lead to html responses like `Sorry, you have been blocked` See also diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index b3fa1c6e..ee8437b6 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -207,7 +207,9 @@ impl Client { let res = res.as_ref(); let res: ResponseData = serde_json::from_str(res).map_err(|err| { error!(target: "etherscan", ?res, "Failed to deserialize response: {}", err); - if is_blocked_by_cloudflare_response(res) { + if res == "Page not found" { + EtherscanError::PageNotFound + } else if is_blocked_by_cloudflare_response(res) { EtherscanError::BlockedByCloudflare } else if is_cloudflare_security_challenge(res) { EtherscanError::CloudFlareSecurityChallenge