chore: add etherscan page not found error (#2126)
This commit is contained in:
parent
060e145ea2
commit
64f2ca696f
|
@ -41,6 +41,8 @@ pub enum EtherscanError {
|
||||||
BlockedByCloudflare,
|
BlockedByCloudflare,
|
||||||
#[error("The Requested prompted a cloudflare captcha security challenge to review the security of your connection before proceeding.")]
|
#[error("The Requested prompted a cloudflare captcha security challenge to review the security of your connection before proceeding.")]
|
||||||
CloudFlareSecurityChallenge,
|
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 <https://community.cloudflare.com/t/sorry-you-have-been-blocked/110790>
|
/// etherscan/polyscan is protected by cloudflare, which can lead to html responses like `Sorry, you have been blocked` See also <https://community.cloudflare.com/t/sorry-you-have-been-blocked/110790>
|
||||||
|
|
|
@ -207,7 +207,9 @@ impl Client {
|
||||||
let res = res.as_ref();
|
let res = res.as_ref();
|
||||||
let res: ResponseData<T> = serde_json::from_str(res).map_err(|err| {
|
let res: ResponseData<T> = serde_json::from_str(res).map_err(|err| {
|
||||||
error!(target: "etherscan", ?res, "Failed to deserialize response: {}", 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
|
EtherscanError::BlockedByCloudflare
|
||||||
} else if is_cloudflare_security_challenge(res) {
|
} else if is_cloudflare_security_challenge(res) {
|
||||||
EtherscanError::CloudFlareSecurityChallenge
|
EtherscanError::CloudFlareSecurityChallenge
|
||||||
|
|
Loading…
Reference in New Issue