Consolidating all RPC error codes
This commit is contained in:
parent
defe688797
commit
1baa150086
@ -37,7 +37,7 @@ use ethcore::filter::Filter as EthcoreFilter;
|
|||||||
use self::ethash::SeedHashCompute;
|
use self::ethash::SeedHashCompute;
|
||||||
use v1::traits::Eth;
|
use v1::traits::Eth;
|
||||||
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, OptionalValue, Index, Filter, Log, Receipt};
|
use v1::types::{Block, BlockTransactions, BlockNumber, Bytes, SyncStatus, SyncInfo, Transaction, CallRequest, OptionalValue, Index, Filter, Log, Receipt};
|
||||||
use v1::impls::dispatch_transaction;
|
use v1::impls::{dispatch_transaction, error_codes};
|
||||||
use serde;
|
use serde;
|
||||||
|
|
||||||
/// Eth rpc implementation.
|
/// Eth rpc implementation.
|
||||||
@ -218,13 +218,9 @@ fn from_params_default_third<F1, F2>(params: Params) -> Result<(F1, F2, BlockNum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be in range [-32099, -32000]
|
|
||||||
const UNSUPPORTED_REQUEST_CODE: i64 = -32000;
|
|
||||||
const NO_WORK_CODE: i64 = -32001;
|
|
||||||
|
|
||||||
fn make_unsupported_err() -> Error {
|
fn make_unsupported_err() -> Error {
|
||||||
Error {
|
Error {
|
||||||
code: ErrorCode::ServerError(UNSUPPORTED_REQUEST_CODE),
|
code: ErrorCode::ServerError(error_codes::UNSUPPORTED_REQUEST_CODE),
|
||||||
message: "Unsupported request.".into(),
|
message: "Unsupported request.".into(),
|
||||||
data: None
|
data: None
|
||||||
}
|
}
|
||||||
@ -232,7 +228,7 @@ fn make_unsupported_err() -> Error {
|
|||||||
|
|
||||||
fn no_work_err() -> Error {
|
fn no_work_err() -> Error {
|
||||||
Error {
|
Error {
|
||||||
code: ErrorCode::ServerError(NO_WORK_CODE),
|
code: ErrorCode::ServerError(error_codes::NO_WORK_CODE),
|
||||||
message: "Still syncing.".into(),
|
message: "Still syncing.".into(),
|
||||||
data: None
|
data: None
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,15 @@ use util::rlp::encode;
|
|||||||
use util::bytes::ToPretty;
|
use util::bytes::ToPretty;
|
||||||
use jsonrpc_core::{Error, ErrorCode, Value, to_value};
|
use jsonrpc_core::{Error, ErrorCode, Value, to_value};
|
||||||
|
|
||||||
|
mod error_codes {
|
||||||
|
// NOTE [ToDr] Codes from [-32099, -32000]
|
||||||
|
pub const UNSUPPORTED_REQUEST_CODE: i64 = -32000;
|
||||||
|
pub const NO_WORK_CODE: i64 = -32001;
|
||||||
|
pub const UNKNOWN_ERROR: i64 = -32002;
|
||||||
|
pub const TRANSACTION_ERROR: i64 = -32010;
|
||||||
|
pub const ACCOUNT_LOCKED: i64 = -32020;
|
||||||
|
}
|
||||||
|
|
||||||
fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result<Value, Error>
|
fn dispatch_transaction<C, M>(client: &C, miner: &M, signed_transaction: SignedTransaction) -> Result<Value, Error>
|
||||||
where C: MiningBlockChainClient, M: MinerService {
|
where C: MiningBlockChainClient, M: MinerService {
|
||||||
let hash = signed_transaction.hash();
|
let hash = signed_transaction.hash();
|
||||||
@ -102,13 +111,6 @@ fn sign_and_dispatch<C, M>(client: &C, miner: &M, request: TransactionRequest, s
|
|||||||
dispatch_transaction(&*client, &*miner, signed_transaction)
|
dispatch_transaction(&*client, &*miner, signed_transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
mod error_codes {
|
|
||||||
// NOTE [ToDr] Codes from -32000 to -32099
|
|
||||||
pub const UNKNOWN_ERROR: i64 = -32002;
|
|
||||||
pub const TRANSACTION_ERROR: i64 = -32010;
|
|
||||||
pub const ACCOUNT_LOCKED: i64 = -32020;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn transaction_error(error: EthcoreError) -> Error {
|
fn transaction_error(error: EthcoreError) -> Error {
|
||||||
use ethcore::error::TransactionError::*;
|
use ethcore::error::TransactionError::*;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user