mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 11:41:04 +00:00
Expunge error-chain (feat. tomaka) (#2662)
* Remove error_chain * Expunge error-chain from rpc and service. * Expunge from transaction pool. * Expunge from node/cli * Expunge from keystore. * Remove some boilerplate. * Fix remaining stuff. * Improve on deprecation message. * Fix issues. * Fix trnsaction pool tests. * Fix the rest. * Fix borked merge. * Update lock
This commit is contained in:
committed by
Gavin Wood
parent
69ffec5822
commit
c162fc5ff1
@@ -14,33 +14,42 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use error_chain::*;
|
||||
use client;
|
||||
use crate::rpc;
|
||||
use crate::errors;
|
||||
pub use internal_errors::*;
|
||||
|
||||
#[allow(deprecated)]
|
||||
mod internal_errors {
|
||||
use super::*;
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
Client(client::error::Error) #[doc = "Client error"];
|
||||
}
|
||||
errors {
|
||||
/// Not implemented yet
|
||||
Unimplemented {
|
||||
description("not yet implemented"),
|
||||
display("Method Not Implemented"),
|
||||
}
|
||||
/// Chain RPC Result type.
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
/// Chain RPC errors.
|
||||
#[derive(Debug, derive_more::Display, derive_more::From)]
|
||||
pub enum Error {
|
||||
/// Client error.
|
||||
Client(client::error::Error),
|
||||
/// Other error type.
|
||||
Other(String),
|
||||
}
|
||||
|
||||
impl std::error::Error for Error {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Client(ref err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Base error code for all chain errors.
|
||||
const BASE_ERROR: i64 = 3000;
|
||||
|
||||
impl From<Error> for rpc::Error {
|
||||
fn from(e: Error) -> Self {
|
||||
match e {
|
||||
Error(ErrorKind::Unimplemented, _) => errors::unimplemented(),
|
||||
Error::Other(message) => rpc::Error {
|
||||
code: rpc::ErrorCode::ServerError(BASE_ERROR + 1),
|
||||
message,
|
||||
data: None,
|
||||
},
|
||||
e => errors::internal(e),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ impl<B, E, Block, RA> Chain<B, E, Block, RA> where
|
||||
let header = best_block_hash()
|
||||
.and_then(|hash| self.header(hash.into()))
|
||||
.and_then(|header| {
|
||||
header.ok_or_else(|| self::error::ErrorKind::Unimplemented.into())
|
||||
header.ok_or_else(|| "Best header missing.".to_owned().into())
|
||||
})
|
||||
.map_err(Into::into);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user