Fix RPC error code conflict (#14315)

* Base error code module

* Base error code module

* fmt
This commit is contained in:
Arkadiy Paronyan
2023-06-09 18:24:49 +02:00
committed by GitHub
parent ee895b3986
commit 881fd1e0dc
9 changed files with 36 additions and 7 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ pub enum Error {
}
/// Base code for all authorship errors.
const BASE_ERROR: i32 = 1000;
const BASE_ERROR: i32 = crate::error::base::AUTHOR;
/// Extrinsic has an invalid format.
const BAD_FORMAT: i32 = BASE_ERROR + 1;
/// Error during transaction verification in runtime.
+1 -1
View File
@@ -37,7 +37,7 @@ pub enum Error {
}
/// Base error code for all chain errors.
const BASE_ERROR: i32 = 3000;
const BASE_ERROR: i32 = crate::error::base::CHAIN;
impl From<Error> for JsonRpseeError {
fn from(e: Error) -> Self {
+1 -1
View File
@@ -44,7 +44,7 @@ pub enum Error {
}
/// Base error code for all dev errors.
const BASE_ERROR: i32 = 6000;
const BASE_ERROR: i32 = crate::error::base::DEV;
impl From<Error> for JsonRpseeError {
fn from(e: Error) -> Self {
+28
View File
@@ -0,0 +1,28 @@
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
/// Base error code for RPC modules.
pub mod base {
pub const AUTHOR: i32 = 1000;
pub const SYSTEM: i32 = 2000;
pub const CHAIN: i32 = 3000;
pub const STATE: i32 = 4000;
pub const OFFCHAIN: i32 = 5000;
pub const DEV: i32 = 6000;
pub const STATEMENT: i32 = 7000;
}
+1
View File
@@ -22,6 +22,7 @@
#![warn(missing_docs)]
mod error;
mod policy;
pub use policy::DenyUnsafe;
@@ -38,7 +38,7 @@ pub enum Error {
}
/// Base error code for all offchain errors.
const BASE_ERROR: i32 = 5000;
const BASE_ERROR: i32 = crate::error::base::OFFCHAIN;
impl From<Error> for JsonRpseeError {
fn from(e: Error) -> Self {
+1 -1
View File
@@ -55,7 +55,7 @@ pub enum Error {
}
/// Base code for all state errors.
const BASE_ERROR: i32 = 4000;
const BASE_ERROR: i32 = crate::error::base::STATE;
impl From<Error> for JsonRpseeError {
fn from(e: Error) -> Self {
@@ -38,7 +38,7 @@ pub enum Error {
}
/// Base error code for all statement errors.
const BASE_ERROR: i32 = 6000;
const BASE_ERROR: i32 = crate::error::base::STATEMENT;
impl From<Error> for JsonRpseeError {
fn from(e: Error) -> Self {
+1 -1
View File
@@ -39,7 +39,7 @@ pub enum Error {
}
// Base code for all system errors.
const BASE_ERROR: i32 = 2000;
const BASE_ERROR: i32 = crate::error::base::SYSTEM;
// Provided block range couldn't be resolved to a list of blocks.
const NOT_HEALTHY_ERROR: i32 = BASE_ERROR + 1;
// Peer argument is malformatted.