Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove thiserror (extracted from #64) #70

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"
readme = "README.md"
version = "0.0.10"
edition = "2021"
rust-version = "1.67.0"
rust-version = "1.81.0"
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved

[features]
default = []
Expand All @@ -28,5 +28,4 @@ proptest = "1.0.0"

[dependencies]
data-encoding = "2.6.0"
thiserror = "1.0.36"
clap = { version = "4.2.4", default-features = false, features = ["std", "derive", "usage", "help"], optional = true }
13 changes: 11 additions & 2 deletions src/bin/stellar-strkey/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ use std::str::FromStr;
use clap::Args;
use stellar_strkey::DecodeError;

#[derive(thiserror::Error, Debug)]
#[derive(Debug)]
pub enum Error {
#[error("decoding {0:?}: {1}")]
Decode(String, DecodeError),
}

impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
Error::Decode(s, inner) => f.write_fmt(format_args!("decoding {s:?}: {inner}")),
}
}
}

impl core::error::Error for Error {}

#[derive(Args, Debug, Clone)]
#[command()]
pub struct Cmd {
Expand Down
13 changes: 11 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
#[derive(thiserror::Error, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum DecodeError {
// TODO: Add meaningful errors for each problem that can occur.
#[error("the strkey is invalid")]
Invalid,
}

impl core::fmt::Display for DecodeError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
match self {
DecodeError::Invalid {} => f.write_str("the strkey is invalid"),
}
}
}

impl core::error::Error for DecodeError {}
Loading