Skip to content
Open
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ documentation = "https://jordanbray.github.io/chess/chess/index.html"
[dependencies]
arrayvec = "0.5.1"
nodrop = "0.1.14"
failure = "0.1.6"
thiserror = "2.0.12"
tracing = { version = "0.1.37", optional = true }

[features]
Expand Down Expand Up @@ -46,7 +46,7 @@ opt-level = 3

[build-dependencies]
rand = { version = "0.7.2", default_features = false, features = ["small_rng"] }
failure = "0.1.6"
thiserror = "2.0.12"

[dev-dependencies]
criterion = "0.3"
Expand Down
20 changes: 10 additions & 10 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
use failure::Fail;
use thiserror::Error;

/// Sometimes, bad stuff happens.
#[derive(Clone, Debug, Fail)]
#[derive(Clone, Debug, Error)]
pub enum Error {
/// The FEN string is invalid
#[fail(display = "Invalid FEN string: {}", fen)]
#[error("Invalid FEN string: {fen}")]
InvalidFen { fen: String },

/// The board created from BoardBuilder was found to be invalid
#[fail(
display = "The board specified did not pass sanity checks. Are you sure the kings exist and the side to move cannot capture the opposing king?"
#[error(
"The board specified did not pass sanity checks. Are you sure the kings exist and the side to move cannot capture the opposing king?"
)]
InvalidBoard,

/// An attempt was made to create a square from an invalid string
#[fail(display = "The string specified does not contain a valid algebraic notation square")]
#[error("The string specified does not contain a valid algebraic notation square")]
InvalidSquare,

/// An attempt was made to create a move from an invalid SAN string
#[fail(display = "The string specified does not contain a valid SAN notation move")]
#[error("The string specified does not contain a valid SAN notation move")]
InvalidSanMove,

/// An atempt was made to create a move from an invalid UCI string
#[fail(display = "The string specified does not contain a valid UCI notation move")]
#[error("The string specified does not contain a valid UCI notation move")]
InvalidUciMove,

/// An attempt was made to convert a string not equal to "1"-"8" to a rank
#[fail(display = "The string specified does not contain a valid rank")]
#[error("The string specified does not contain a valid rank")]
InvalidRank,

/// An attempt was made to convert a string not equal to "a"-"h" to a file
#[fail(display = "The string specified does not contain a valid file")]
#[error("The string specified does not contain a valid file")]
InvalidFile,
}