mirror of
https://github.com/mozilla-services/syncstorage-rs.git
synced 2026-05-05 20:26:26 +02:00
Feat/772 (#784)
* feat: Better "Archive" header error, don't report some HAWK errors Closes: #771, #772
This commit is contained in:
parent
af5234d4ce
commit
c11b3af354
@ -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
|
||||
|
||||
@ -24,6 +24,12 @@ pub struct HawkError {
|
||||
inner: Context<HawkErrorKind>,
|
||||
}
|
||||
|
||||
impl HawkError {
|
||||
pub fn kind(&self) -> &HawkErrorKind {
|
||||
self.inner.get_context()
|
||||
}
|
||||
}
|
||||
|
||||
/// Causes of HAWK errors.
|
||||
#[derive(Debug, Fail)]
|
||||
pub enum HawkErrorKind {
|
||||
|
||||
@ -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),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user