Skip to content
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
23 changes: 23 additions & 0 deletions kormir/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ use std::fmt::{Display, Formatter};
#[derive(Debug, Clone)]
pub enum Error {
/// Invalid argument given
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since InvalidArgument was removed, this is a breaking change for anyone using Error::InvalidArgument

May want to add in changelog. The new errors you added are better though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted it and made it deprecated. Will be removed in the next minor release.

#[deprecated(since = "1.0.9")]
InvalidArgument,
/// Invalid event ID given
InvalidEventId,
/// Invalid outcomes given
InvalidOutcomes,
/// Invalid base given
InvalidBase,
/// Invalid number of digits given
InvalidNumberOfDigits,
/// Invalid nonces given
InvalidNonces,
/// Attempted to sign an event that was already signed
EventAlreadySigned,
/// Event data was not found
Expand All @@ -13,18 +24,30 @@ pub enum Error {
StorageFailure,
/// User gave an invalid outcome
InvalidOutcome,
/// User gave an invalid event descriptor
InvalidEventDescriptor,
/// User gave an invalid announcement
InvalidAnnouncement,
/// An error that should never happen, if it does it's a bug
Internal,
}

impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
#[allow(deprecated)]
Error::InvalidArgument => write!(f, "Invalid argument given"),
Error::InvalidEventId => write!(f, "Invalid event ID given"),
Error::InvalidOutcomes => write!(f, "Invalid outcomes given"),
Error::InvalidBase => write!(f, "Invalid base given"),
Error::InvalidNumberOfDigits => write!(f, "Invalid number of digits given"),
Error::InvalidNonces => write!(f, "Invalid nonces given"),
Error::EventAlreadySigned => write!(f, "Event already signed"),
Error::NotFound => write!(f, "Event data not found"),
Error::StorageFailure => write!(f, "Storage failure"),
Error::InvalidOutcome => write!(f, "Invalid outcome"),
Error::InvalidEventDescriptor => write!(f, "Invalid event descriptor"),
Error::InvalidAnnouncement => write!(f, "Invalid announcement"),
Error::Internal => write!(f, "Internal error"),
}
}
Expand Down
Loading
Loading