Skip to content

Commit c8bb20f

Browse files
committed
refactor: review
1 parent 0896ba5 commit c8bb20f

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

clarity/src/vm/costs/mod.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,20 @@ pub enum CostErrors {
419419

420420
impl fmt::Display for CostErrors {
421421
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
422-
write!(f, "{:?}", self)
422+
match self {
423+
CostErrors::CostComputationFailed(ref s) => write!(f, "Cost computation failed: {}", s),
424+
CostErrors::CostOverflow => write!(f, "Cost overflow"),
425+
CostErrors::CostBalanceExceeded(ref total, ref limit) => {
426+
write!(f, "Cost balance exceeded: total {}, limit {}", total, limit)
427+
}
428+
CostErrors::MemoryBalanceExceeded(ref used, ref limit) => {
429+
write!(f, "Memory balance exceeded: used {}, limit {}", used, limit)
430+
}
431+
CostErrors::CostContractLoadFailure => write!(f, "Failed to load cost contract"),
432+
CostErrors::InterpreterFailure => write!(f, "Interpreter failure"),
433+
CostErrors::Expect(ref s) => write!(f, "Expectation failed: {}", s),
434+
CostErrors::ExecutionTimeExpired => write!(f, "Execution time expired"),
435+
}
423436
}
424437
}
425438

stacks-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ rand_core = { workspace = true }
7979
proptest = "1.6.0"
8080

8181
[features]
82-
default = ["rusqlite", "developer-mode"]
82+
default = ["developer-mode"]
8383
developer-mode = []
8484
slog_json = ["slog-json"]
8585
rusqlite = ["dep:rusqlite"]

stacks-common/src/deps_common/bitcoin/util/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::{error, fmt};
2222

2323
use crate::deps_common::bitcoin::network;
2424
use crate::deps_common::bitcoin::network::serialize;
25-
use crate::util::secp256k1::Error as Secp256k1Error;
2625

2726
/// A trait which allows numbers to act as fixed-size bit arrays
2827
pub trait BitArray {
@@ -49,8 +48,6 @@ pub trait BitArray {
4948
/// if appropriate.
5049
#[derive(Debug)]
5150
pub enum Error {
52-
/// secp-related error
53-
Secp256k1(Secp256k1Error),
5451
/// Serialization error
5552
Serialize(serialize::Error),
5653
/// Network error
@@ -64,7 +61,6 @@ pub enum Error {
6461
impl fmt::Display for Error {
6562
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6663
match *self {
67-
Error::Secp256k1(ref e) => fmt::Display::fmt(e, f),
6864
Error::Serialize(ref e) => fmt::Display::fmt(e, f),
6965
Error::Network(ref e) => fmt::Display::fmt(e, f),
7066
Error::SpvBadProofOfWork => f.write_str("target correct but not attained"),
@@ -76,21 +72,13 @@ impl fmt::Display for Error {
7672
impl error::Error for Error {
7773
fn cause(&self) -> Option<&dyn error::Error> {
7874
match *self {
79-
Error::Secp256k1(ref e) => Some(e),
8075
Error::Serialize(ref e) => Some(e),
8176
Error::Network(ref e) => Some(e),
8277
Error::SpvBadProofOfWork | Error::SpvBadTarget => None,
8378
}
8479
}
8580
}
8681

87-
#[doc(hidden)]
88-
impl From<Secp256k1Error> for Error {
89-
fn from(e: Secp256k1Error) -> Error {
90-
Error::Secp256k1(e)
91-
}
92-
}
93-
9482
#[doc(hidden)]
9583
impl From<serialize::Error> for Error {
9684
fn from(e: serialize::Error) -> Error {

0 commit comments

Comments
 (0)