Renamed 'InvalidQueryParams' to 'BadRequest', since it is a more general error that is returned in a number of cases.

This commit is contained in:
Luke Anderson
2019-09-13 20:52:12 +10:00
parent f48311900e
commit d3ce182ddc
6 changed files with 34 additions and 41 deletions

View File

@@ -139,10 +139,7 @@ pub fn get_validators<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiR
.parse::<u64>()
.map(Epoch::from)
.map_err(|e| {
ApiError::InvalidQueryParams(format!(
"Invalid epoch parameter, must be a u64. {:?}",
e
))
ApiError::BadRequest(format!("Invalid epoch parameter, must be a u64. {:?}", e))
})?,
// In this case, our url query did not contain any parameters, so we take the default
Err(_) => beacon_chain.epoch().map_err(|e| {
@@ -181,7 +178,7 @@ pub fn get_state<T: BeaconChainTypes + 'static>(req: Request<Body>) -> ApiResult
let query_params = ["root", "slot"];
query.first_of(&query_params)?
}
Err(ApiError::InvalidQueryParams(_)) => {
Err(ApiError::BadRequest(_)) => {
// No parameters provided at all, use current slot.
(String::from("slot"), head_state.slot.to_string())
}