referrerpolicy=no-referrer-when-downgrade

substrate_relay_helper/
error.rs

1// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2// This file is part of Parity Bridges Common.
3
4// Parity Bridges Common is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Parity Bridges Common is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Parity Bridges Common.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Relay errors.
18
19use relay_substrate_client as client;
20use sp_consensus_grandpa::AuthorityList;
21use sp_runtime::traits::MaybeDisplay;
22use std::fmt::Debug;
23use thiserror::Error;
24
25/// Relay errors.
26#[derive(Error, Debug)]
27pub enum Error<Hash: Debug + MaybeDisplay, HeaderNumber: Debug + MaybeDisplay> {
28	/// Failed to submit signed extrinsic from to the target chain.
29	#[error("Failed to submit {0} transaction: {1:?}")]
30	SubmitTransaction(&'static str, client::Error),
31	/// Failed subscribe to justification stream of the source chain.
32	#[error("Failed to subscribe to {0} justifications: {1:?}")]
33	Subscribe(&'static str, client::Error),
34	/// Failed subscribe to read justification from the source chain (client error).
35	#[error("Failed to read {0} justification from the stream: {1}")]
36	ReadJustification(&'static str, client::Error),
37	/// Failed subscribe to read justification from the source chain (stream ended).
38	#[error("Failed to read {0} justification from the stream: stream has ended unexpectedly")]
39	ReadJustificationStreamEnded(&'static str),
40	/// Failed subscribe to decode justification from the source chain.
41	#[error("Failed to decode {0} justification: {1:?}")]
42	DecodeJustification(&'static str, codec::Error),
43	/// GRANDPA authorities read from the source chain are invalid.
44	#[error("Read invalid {0} authorities set: {1:?}")]
45	ReadInvalidAuthorities(&'static str, AuthorityList),
46	/// Failed to guess initial GRANDPA authorities at the given header of the source chain.
47	#[error("Failed to guess initial {0} GRANDPA authorities set id: checked all possible ids in range [0; {1}]")]
48	GuessInitialAuthorities(&'static str, HeaderNumber),
49	/// Failed to retrieve GRANDPA authorities at the given header from the source chain.
50	#[error("Failed to retrieve {0} GRANDPA authorities set at header {1}: {2:?}")]
51	RetrieveAuthorities(&'static str, Hash, client::Error),
52	/// Failed to decode GRANDPA authorities at the given header of the source chain.
53	#[error("Failed to decode {0} GRANDPA authorities set at header {1}: {2:?}")]
54	DecodeAuthorities(&'static str, Hash, codec::Error),
55	/// Failed to retrieve header by the hash from the source chain.
56	#[error("Failed to retrieve {0} header with hash {1}: {2:?}")]
57	RetrieveHeader(&'static str, Hash, client::Error),
58	/// Failed to submit signed extrinsic from to the target chain.
59	#[error(
60		"Failed to retrieve `is_initialized` flag of the with-{0} finality pallet at {1}: {2:?}"
61	)]
62	IsInitializedRetrieve(&'static str, &'static str, client::Error),
63}