Files
nym/common/client-libs/validator-client/src/error.rs
T
Bogdan-Ștefan Neacşu 973c30592f Use cached topology for clients (#674)
* Add validator-api common client

* Call validator-api from different clients for gateway topology

* Call validator-api from different clients for mixnode topology

* Use consts for the validator-api queries

* Rename the new query_validator function to query_validator_api

* Add mut to mixnode validator client

* Add refreshValidatorAPIGateways as a way to get the gateways...

... from validator-api

* Add refreshValidatorAPIGateways as a way to get the mixnodes...

... from validator-api

* Add yet another mut

* Change the port to validator-api service when querying the topology

* Add parsing check on the config phase...

... to make sure the validator URLs are in the correct format.

* Fix another clippy error

* Use all provided validators instead of just the first one

* The mutable reference was not actually needed, so remove it

* Use global variable for validator-api port

* Use url crate for checking the format and changing the port

* Use URL for parsing and move constants of validator-api to index.ts...

... until we find a way to link to the values from the validator-api
crate.

* Change global variables naming and have the API version into each API query

* Revert the changes to the index on connect...

... as they were working correctly before.

* Use all provided validators for mixnodes as well

* Remove location and layer
2021-07-09 11:50:41 +01:00

52 lines
1.2 KiB
Rust

use crate::validator_api;
use serde::Deserialize;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ValidatorClientError {
#[error("There was an issue with the REST request - {source}")]
ReqwestClientError {
#[from]
source: reqwest::Error,
},
#[error("There was an issue with the validator-api request - {source}")]
ValidatorAPIError {
#[from]
source: validator_api::error::ValidatorAPIClientError,
},
#[error("An IO error has occured: {source}")]
IoError {
#[from]
source: std::io::Error,
},
#[error("There was an issue with the validator client - {0}")]
ValidatorError(String),
}
// this is the case of message like
/*
{
"code": 12,
"message": "Not Implemented",
"details": [
]
}
*/
// I didn't manage to find where it exactly originates, nor what the correct types should be
// so all of those are some educated guesses
#[derive(Error, Debug, Deserialize)]
#[error("code: {code} - {message}")]
pub(super) struct CodedError {
code: u32,
message: String,
details: Vec<(String, String)>,
}
#[derive(Error, Deserialize, Debug)]
#[error("{error}")]
pub(super) struct SmartQueryError {
pub(super) error: String,
}