Skip to content

Instantly share code, notes, and snippets.

@pjenvey
Created October 18, 2018 20:46
Show Gist options
  • Save pjenvey/c3b71ce0d684f07a6bf4b28f5e66b81b to your computer and use it in GitHub Desktop.
Save pjenvey/c3b71ce0d684f07a6bf4b28f5e66b81b to your computer and use it in GitHub Desktop.
diff --git a/src/web/error.rs b/src/web/error.rs
index c6035be0..0f855ebd 100644
--- a/src/web/error.rs
+++ b/src/web/error.rs
@@ -4,7 +4,7 @@ use std::fmt;
use actix_web::http::header::ToStrError;
use base64::DecodeError;
-use failure::{Backtrace, Context, Fail};
+use failure::{Backtrace, Context, Fail, SyncFailure};
use hawk::Error as ParseError;
use hmac::crypto_mac::{InvalidKeyLength, MacError};
use serde_json::Error as JsonError;
@@ -54,7 +54,7 @@ pub enum HawkErrorKind {
MissingPrefix,
#[fail(display = "{}", _0)]
- Parse(ParseError),
+ Parse(SyncFailure<ParseError>),
#[fail(display = "id property is too short")]
TruncatedId,
@@ -67,7 +67,12 @@ from_error!(InvalidKeyLength, ApiError, HawkErrorKind::InvalidKeyLength);
from_error!(JsonError, ApiError, HawkErrorKind::Json);
from_error!(MacError, ApiError, HawkErrorKind::Hmac);
from_error!(ToStrError, ApiError, HawkErrorKind::Header);
-from_error!(ParseError, ApiError, HawkErrorKind::Parse);
+
+impl From<ParseError> for ApiError {
+ fn from(inner: ParseError) -> ApiError {
+ HawkErrorKind::Parse(SyncFailure::new(inner)).into()
+ }
+}
impl From<HawkErrorKind> for ApiError {
fn from(kind: HawkErrorKind) -> Self {
@@ -75,5 +80,3 @@ impl From<HawkErrorKind> for ApiError {
hawk_error.into()
}
}
-
-unsafe impl Sync for HawkErrorKind {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment