1// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2// This file is part of Parity Bridges Common.
34// 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.
89// 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.
1314// 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/>.
1617//! Relay errors.
1819use relay_substrate_client as client;
20use sp_consensus_grandpa::AuthorityList;
21use sp_runtime::traits::MaybeDisplay;
22use std::fmt::Debug;
23use thiserror::Error;
2425/// 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:?}")]
30SubmitTransaction(&'static str, client::Error),
31/// Failed subscribe to justification stream of the source chain.
32#[error("Failed to subscribe to {0} justifications: {1:?}")]
33Subscribe(&'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}")]
36ReadJustification(&'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")]
39ReadJustificationStreamEnded(&'static str),
40/// Failed subscribe to decode justification from the source chain.
41#[error("Failed to decode {0} justification: {1:?}")]
42DecodeJustification(&'static str, codec::Error),
43/// GRANDPA authorities read from the source chain are invalid.
44#[error("Read invalid {0} authorities set: {1:?}")]
45ReadInvalidAuthorities(&'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}]")]
48GuessInitialAuthorities(&'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:?}")]
51RetrieveAuthorities(&'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:?}")]
54DecodeAuthorities(&'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:?}")]
57RetrieveHeader(&'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)]
62IsInitializedRetrieve(&'static str, &'static str, client::Error),
63}