Rpc: Add custom error for BigTable data not found (#14762)

* Expose not-found bigtable error

* Add custom rpc error for bigtable data not found

* Return custom rpc error when bigtable block is not found

* Generalize long-term storage
This commit is contained in:
Tyera Eulberg
2021-01-21 21:40:47 -07:00
committed by GitHub
parent 12410541a4
commit 71e9958e06
3 changed files with 48 additions and 7 deletions

View File

@ -12,6 +12,7 @@ pub const JSON_RPC_SERVER_ERROR_NODE_UNHEALTHLY: i64 = -32005;
pub const JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: i64 = -32006;
pub const JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: i64 = -32007;
pub const JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: i64 = -32008;
pub const JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: i64 = -32009;
pub enum RpcCustomError {
BlockCleanedUp {
@ -34,6 +35,9 @@ pub enum RpcCustomError {
slot: Slot,
},
NoSnapshot,
LongTermStorageSlotSkipped {
slot: Slot,
},
}
#[derive(Debug, Serialize, Deserialize)]
@ -106,6 +110,11 @@ impl From<RpcCustomError> for Error {
message: "No snapshot".to_string(),
data: None,
},
RpcCustomError::LongTermStorageSlotSkipped { slot } => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED),
message: format!("Slot {} was skipped, or missing in long-term storage", slot),
data: None,
},
}
}
}