Improve error message

This commit is contained in:
asonix 2022-12-08 21:12:38 -06:00
parent 1224b3201c
commit 3e2639670e
2 changed files with 21 additions and 3 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "http-signature-normalization-actix"
description = "An HTTP Signatures library that leaves the signing to you"
version = "0.7.0"
version = "0.7.1"
authors = ["asonix <asonix@asonix.dog>"]
license = "AGPL-3.0"
readme = "README.md"

View file

@ -72,14 +72,32 @@ impl std::fmt::Display for HeaderKind {
}
}
#[derive(Clone, Debug, thiserror::Error)]
#[error("Failed to verify http signature, {kind}")]
#[derive(Clone)]
#[doc(hidden)]
pub struct VerifyError {
context: SpanTrace,
kind: VerifyErrorKind,
}
impl std::fmt::Debug for VerifyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{:?}", self.kind)
}
}
impl std::fmt::Display for VerifyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "{}", self.kind)?;
std::fmt::Display::fmt(&self.context, f)
}
}
impl std::error::Error for VerifyError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
self.kind.source()
}
}
#[derive(Clone, Debug, thiserror::Error)]
enum VerifyErrorKind {
#[error("Signature or Authorization header is missing")]