diff --git a/src/error.rs b/src/error.rs index 85588b97..e2d96dd6 100644 --- a/src/error.rs +++ b/src/error.rs @@ -24,7 +24,7 @@ use serde::{ use crate::db::error::{DbError, DbErrorKind}; use crate::server::metrics::Metrics; use crate::server::ServerState; -use crate::web::error::{HawkError, ValidationError, ValidationErrorKind}; +use crate::web::error::{HawkError, HawkErrorKind, ValidationError, ValidationErrorKind}; use crate::web::extractors::RequestErrorLocation; /// Legacy Sync 1.1 error codes, which Sync 1.5 also returns by replacing the descriptive JSON @@ -127,6 +127,11 @@ impl ApiError { DbErrorKind::Conflict => return false, _ => (), }, + ApiErrorKind::Hawk(hawke) => match hawke.kind() { + HawkErrorKind::MissingHeader => return false, + HawkErrorKind::InvalidHeader => return false, + _ => (), + }, _ => (), } true diff --git a/src/web/error.rs b/src/web/error.rs index 7bb21f0c..a675211b 100644 --- a/src/web/error.rs +++ b/src/web/error.rs @@ -24,6 +24,12 @@ pub struct HawkError { inner: Context, } +impl HawkError { + pub fn kind(&self) -> &HawkErrorKind { + self.inner.get_context() + } +} + /// Causes of HAWK errors. #[derive(Debug, Fail)] pub enum HawkErrorKind { diff --git a/src/web/extractors.rs b/src/web/extractors.rs index e366411e..ba1a52d8 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -788,7 +788,7 @@ impl FromRequest for CollectionRequest { "application/json" | "" => ReplyFormat::Json, _ => { return Err(ValidationErrorKind::FromDetails( - "Invalid accept".to_string(), + format!("Invalid Accept header specified: {:?}", accept), RequestErrorLocation::Header, Some("accept".to_string()), Some(tags),