Skip to content

Commit

Permalink
Merge pull request #3 from diogo464/impl-error
Browse files Browse the repository at this point in the history
fix: impl error for Error
  • Loading branch information
4kimov authored Oct 10, 2023
2 parents 6834fb4 + 95ad5d1 commit a895c45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ readme = "README.md"
keywords = ["ids", "encode", "short", "sqids", "hashids"]

[dependencies]
derive_more = "0.99.17"
serde = "1.0.188"
serde_json = "1.0.107"
thiserror = "1.0.49"
13 changes: 7 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
use derive_more::Display;
use std::{cmp::min, collections::HashSet, result};

#[derive(Display, Debug, Eq, PartialEq)]
use thiserror::Error;

#[derive(Error, Debug, Eq, PartialEq)]
pub enum Error {
#[display(fmt = "Alphabet cannot contain multibyte characters")]
#[error("Alphabet cannot contain multibyte characters")]
AlphabetMultibyteCharacters,
#[display(fmt = "Alphabet length must be at least 3")]
#[error("Alphabet length must be at least 3")]
AlphabetLength,
#[display(fmt = "Alphabet must contain unique characters")]
#[error("Alphabet must contain unique characters")]
AlphabetUniqueCharacters,
#[display(fmt = "Reached max attempts to re-generate the ID")]
#[error("Reached max attempts to re-generate the ID")]
BlocklistMaxAttempts,
}

Expand Down

0 comments on commit a895c45

Please sign in to comment.