Skip to content

Commit

Permalink
feat(miette): Add miette and derive Diagnostic for Error
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Feb 19, 2023
1 parent 9dbb1e8 commit c2071f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rust-version = "1.57.0"
base64 = "0.21.0"
digest = "0.10.6"
hex = "0.4.3"
miette = "5.5.0"
serde = { version = "1.0.152", optional = true }
sha-1 = "0.10.1"
sha2 = "0.10.6"
Expand Down
5 changes: 4 additions & 1 deletion src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
use miette::Diagnostic;
use thiserror::Error;

use crate::Integrity;

/// Integrity-related error values.
#[derive(Error, Debug, Clone, PartialEq, Eq)]
#[derive(Diagnostic, Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
/// Error parsing an SRI string into an Integrity object.
#[error("Failed to parse subresource integrity string: {0}")]
#[diagnostic(code(ssri::parse_integrity_error), url(docsrs))]
ParseIntegrityError(String),
/// Error matching two Integrity values.
#[error("Integrity check failed.\n\tWanted: {0}\n\tActual: {1}")]
#[diagnostic(code(ssri::integrity_check_error), url(docsrs))]
IntegrityCheckError(Integrity, Integrity),
}

0 comments on commit c2071f6

Please sign in to comment.