Skip to content

Commit

Permalink
Include NotGrpc error condition
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jun 16, 2024
1 parent b344975 commit 8b83752
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/cosmos/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ pub enum QueryErrorDetails {
RateLimited { source: tonic::Status },
#[error("The gRPC server is returning a 'forbidden' response: {source:?}")]
Forbidden { source: tonic::Status },
#[error("Server returned response that does not look like valid gRPC: {source:?}")]
NotGrpc { source: tonic::Status },
}

/// Different known Cosmos SDK error codes
Expand Down Expand Up @@ -540,6 +542,7 @@ impl QueryErrorDetails {
QueryErrorDetails::AccountSequenceMismatch { .. } => ConnectionIsFine,
QueryErrorDetails::RateLimited { .. } => NetworkIssue,
QueryErrorDetails::Forbidden { .. } => NetworkIssue,
QueryErrorDetails::NotGrpc { .. } => NetworkIssue,
}
}

Expand Down Expand Up @@ -605,6 +608,14 @@ impl QueryErrorDetails {
};
}

if err.message().contains("status: 405") {
return QueryErrorDetails::NotGrpc { source: err };
}

if err.message().contains("invalid compression flag") {
return QueryErrorDetails::NotGrpc { source: err };
}

QueryErrorDetails::Unknown(err)
}

Expand All @@ -623,7 +634,8 @@ impl QueryErrorDetails {
| QueryErrorDetails::TransportError { .. }
| QueryErrorDetails::BlocksLagDetected { .. }
| QueryErrorDetails::NoNewBlockFound { .. }
| QueryErrorDetails::AccountSequenceMismatch(_) => false,
| QueryErrorDetails::AccountSequenceMismatch(_)
| QueryErrorDetails::NotGrpc { .. } => false,
QueryErrorDetails::RateLimited { .. } | QueryErrorDetails::Forbidden { .. } => true,
}
}
Expand Down

0 comments on commit 8b83752

Please sign in to comment.