referrerpolicy=no-referrer-when-downgrade

relay_utils/
error.rs

1// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2// This file is part of Parity Bridges Common.
3// Parity Bridges Common is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7// Parity Bridges Common is distributed in the hope that it will be useful,
8// but WITHOUT ANY WARRANTY; without even the implied warranty of
9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10// GNU General Public License for more details.
11// You should have received a copy of the GNU General Public License
12// along with Parity Bridges Common.  If not, see <http://www.gnu.org/licenses/>.
13
14use std::net::AddrParseError;
15use thiserror::Error;
16
17/// Result type used by relay utilities.
18pub type Result<T> = std::result::Result<T, Error>;
19
20/// Relay utilities errors.
21#[derive(Error, Debug)]
22pub enum Error {
23	/// Failed to request a float value from HTTP service.
24	#[error("Failed to fetch token price from remote server: {0}")]
25	FetchTokenPrice(#[source] anyhow::Error),
26	/// Failed to parse the response from HTTP service.
27	#[error("Failed to parse HTTP service response: {0:?}. Response: {1:?}")]
28	ParseHttp(serde_json::Error, String),
29	/// Failed to select response value from the Json response.
30	#[error("Failed to select value from response: {0:?}. Response: {1:?}")]
31	SelectResponseValue(jsonpath_lib::JsonPathError, String),
32	/// Failed to parse float value from the selected value.
33	#[error(
34		"Failed to parse float value {0:?} from response. It is assumed to be positive and normal"
35	)]
36	ParseFloat(f64),
37	/// Couldn't found value in the JSON response.
38	#[error("Missing required value from response: {0:?}")]
39	MissingResponseValue(String),
40	/// Invalid host address was used for exposing Prometheus metrics.
41	#[error("Invalid host {0} is used to expose Prometheus metrics: {1}")]
42	ExposingMetricsInvalidHost(String, AddrParseError),
43	/// Prometheus error.
44	#[error("{0}")]
45	Prometheus(#[from] prometheus_endpoint::prometheus::Error),
46}