chore: rewrite all error messages for consistency (#5176)

Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com>
This commit is contained in:
DaniPopes
2023-10-25 22:12:03 +02:00
committed by GitHub
parent 1c0373b322
commit e05dba69ce
73 changed files with 649 additions and 599 deletions

View File

@@ -343,10 +343,10 @@ impl Decodable for BlockHashOrNumber {
}
#[derive(Debug, thiserror::Error)]
#[error("Failed to parse `{input}` as integer: {pares_int_error} or as hex: {hex_error}")]
#[error("failed to parse {input:?} as a number: {parse_int_error} or hash: {hex_error}")]
pub struct ParseBlockHashOrNumberError {
input: String,
pares_int_error: ParseIntError,
parse_int_error: ParseIntError,
hex_error: crate::hex::FromHexError,
}
@@ -360,7 +360,7 @@ impl FromStr for BlockHashOrNumber {
Ok(val) => Ok(val.into()),
Err(hex_error) => Err(ParseBlockHashOrNumberError {
input: s.to_string(),
pares_int_error,
parse_int_error: pares_int_error,
hex_error,
}),
},

View File

@@ -59,11 +59,11 @@ pub fn load_trusted_setup_from_bytes(bytes: &[u8]) -> Result<KzgSettings, LoadKz
pub enum LoadKzgSettingsError {
/// Failed to create temp file to store bytes for loading [KzgSettings] via
/// [KzgSettings::load_trusted_setup_file].
#[error("Failed to setup temp file: {0:?}")]
#[error("failed to setup temp file: {0}")]
TempFileErr(#[from] std::io::Error),
/// Kzg error
#[error("Kzg error: {0:?}")]
KzgError(c_kzg::Error),
#[error("KZG error: {0:?}")]
KzgError(#[from] c_kzg::Error),
}
#[cfg(test)]

View File

@@ -146,10 +146,10 @@ impl<'a> Arbitrary<'a> for IntegerList {
#[derive(Debug, thiserror::Error)]
pub enum EliasFanoError {
/// The provided input is invalid.
#[error("The provided input is invalid.")]
#[error("the provided input is invalid")]
InvalidInput,
/// Failed to deserialize data into type.
#[error("Failed to deserialize data into type.")]
#[error("failed to deserialize data into type")]
FailedDeserialize,
}

View File

@@ -183,11 +183,11 @@ fn parse_nodes(nodes: impl IntoIterator<Item = impl AsRef<str>>) -> Vec<NodeReco
/// Possible error types when parsing a `NodeRecord`
#[derive(Debug, thiserror::Error)]
pub enum NodeRecordParseError {
#[error("Failed to parse url: {0}")]
#[error("failed to parse url: {0}")]
InvalidUrl(String),
#[error("Failed to parse id")]
#[error("failed to parse id")]
InvalidId(String),
#[error("Failed to discport query: {0}")]
#[error("failed to discport query: {0}")]
Discport(ParseIntError),
}

View File

@@ -43,10 +43,10 @@ impl PruneSegment {
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum PruneSegmentError {
/// Invalid configuration of a prune segment.
#[error("The configuration provided for {0} is invalid.")]
#[error("the configuration provided for {0} is invalid")]
Configuration(PruneSegment),
/// Receipts have been pruned
#[error("Receipts have been pruned")]
#[error("receipts have been pruned")]
ReceiptsPruned,
}

View File

@@ -331,22 +331,16 @@ impl TxEip4844 {
#[derive(Debug, thiserror::Error)]
pub enum BlobTransactionValidationError {
/// Proof validation failed.
#[error("invalid kzg proof")]
#[error("invalid KZG proof")]
InvalidProof,
/// An error returned by the [kzg] library
#[error("kzg error: {0:?}")]
KZGError(kzg::Error),
/// The inner transaction is not a blob transaction
/// An error returned by [`kzg`].
#[error("KZG error: {0:?}")]
KZGError(#[from] kzg::Error),
/// The inner transaction is not a blob transaction.
#[error("unable to verify proof for non blob transaction: {0}")]
NotBlobTransaction(u8),
}
impl From<kzg::Error> for BlobTransactionValidationError {
fn from(value: kzg::Error) -> Self {
Self::KZGError(value)
}
}
/// A response to `GetPooledTransactions` that includes blob data, their commitments, and their
/// corresponding proofs.
///

View File

@@ -6,49 +6,51 @@ use crate::U256;
#[derive(Debug, Clone, Eq, PartialEq, thiserror::Error)]
pub enum InvalidTransactionError {
/// The sender does not have enough funds to cover the transaction fees
#[error("Sender does not have enough funds ({available_funds:?}) to cover transaction fees: {cost:?}.")]
#[error(
"sender does not have enough funds ({available_funds}) to cover transaction fees: {cost}"
)]
InsufficientFunds { cost: U256, available_funds: U256 },
/// The nonce is lower than the account's nonce, or there is a nonce gap present.
///
/// This is a consensus error.
#[error("Transaction nonce is not consistent.")]
#[error("transaction nonce is not consistent")]
NonceNotConsistent,
/// The transaction is before Spurious Dragon and has a chain ID
#[error("Transactions before Spurious Dragon should not have a chain ID.")]
#[error("transactions before Spurious Dragon should not have a chain ID")]
OldLegacyChainId,
/// The chain ID in the transaction does not match the current network configuration.
#[error("Transaction's chain ID does not match.")]
#[error("transaction's chain ID does not match")]
ChainIdMismatch,
/// The transaction requires EIP-2930 which is not enabled currently.
#[error("EIP-2930 transactions are disabled.")]
#[error("EIP-2930 transactions are disabled")]
Eip2930Disabled,
/// The transaction requires EIP-1559 which is not enabled currently.
#[error("EIP-1559 transactions are disabled.")]
#[error("EIP-1559 transactions are disabled")]
Eip1559Disabled,
/// The transaction requires EIP-4844 which is not enabled currently.
#[error("EIP-4844 transactions are disabled.")]
#[error("EIP-4844 transactions are disabled")]
Eip4844Disabled,
/// Thrown if a transaction is not supported in the current network configuration.
#[error("Transaction type not supported")]
#[error("transaction type not supported")]
TxTypeNotSupported,
/// The calculated gas of the transaction exceeds `u64::MAX`.
#[error("Gas overflow (maximum of u64)")]
#[error("gas overflow (maximum of u64)")]
GasUintOverflow,
/// The transaction is specified to use less gas than required to start the
/// invocation.
#[error("Intrinsic gas too low")]
#[error("intrinsic gas too low")]
GasTooLow,
/// The transaction gas exceeds the limit
#[error("Intrinsic gas too high")]
#[error("intrinsic gas too high")]
GasTooHigh,
/// Thrown to ensure no one is able to specify a transaction with a tip higher than the total
/// fee cap.
#[error("Max priority fee per gas higher than max fee per gas")]
#[error("max priority fee per gas higher than max fee per gas")]
TipAboveFeeCap,
/// Thrown post London if the transaction's fee is less than the base fee of the block
#[error("Max fee per gas less than block base fee")]
#[error("max fee per gas less than block base fee")]
FeeCapTooLow,
/// Thrown if the sender of a transaction is a contract.
#[error("Transaction signer has bytecode set.")]
#[error("transaction signer has bytecode set")]
SignerAccountHasBytecode,
}