mirror of
https://github.com/jmic/altcha-lib-rs.git
synced 2026-01-25 04:16:40 +00:00
add support for thiserror
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "altcha-lib-rs"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
edition = "2021"
|
||||
authors = ["jmic <jmic@users.noreply.github.com>"]
|
||||
description = "Community implementation of the Altcha library in Rust for your own server application to create and validate challenges and responses."
|
||||
@@ -25,6 +25,7 @@ sha1 = "0"
|
||||
hmac = "0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0", optional = true }
|
||||
thiserror = "2.0.12"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
@@ -32,4 +33,4 @@ json = ["serde_json"]
|
||||
|
||||
[dev-dependencies]
|
||||
actix-web = "4"
|
||||
base64 = "0.22"
|
||||
base64 = "0.22"
|
||||
|
||||
12
src/error.rs
12
src/error.rs
@@ -1,15 +1,25 @@
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[cfg(feature = "json")]
|
||||
#[error("JSON parsing error: {0}")]
|
||||
ParseJson(serde_json::Error),
|
||||
#[error("Integer parsing error: {0}")]
|
||||
ParseInteger(std::num::ParseIntError),
|
||||
#[error("Expiration parsing error: {0}")]
|
||||
ParseExpire(String),
|
||||
#[error("Solution expired: {0}")]
|
||||
VerificationFailedExpired(String),
|
||||
#[error("Solution does not match the challenge: {0}")]
|
||||
VerificationMismatchChallenge(String),
|
||||
#[error("Signature in the solution does not match the challenge: {0}")]
|
||||
VerificationMismatchSignature(String),
|
||||
#[error("Max number reached: {0}")]
|
||||
SolveChallengeMaxNumberReached(String),
|
||||
#[error("Wrong challenge input: {0}")]
|
||||
WrongChallengeInput(String),
|
||||
#[error("Altcha error: {0}")]
|
||||
General(String),
|
||||
#[error("Error in the randomizer: {0}")]
|
||||
RandError(rand::distr::uniform::Error),
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user