1
1
use std:: error:: Error as StdError ;
2
2
use std:: fmt;
3
3
use std:: result;
4
+ use std:: sync:: Arc ;
4
5
5
6
/// A crate private constructor for `Error`.
6
7
pub ( crate ) fn new_error ( kind : ErrorKind ) -> Error {
@@ -11,7 +12,7 @@ pub(crate) fn new_error(kind: ErrorKind) -> Error {
11
12
pub type Result < T > = result:: Result < T , Error > ;
12
13
13
14
/// An error that can occur when encoding/decoding JWTs
14
- #[ derive( Debug , Eq , PartialEq ) ]
15
+ #[ derive( Clone , Debug , Eq , PartialEq ) ]
15
16
pub struct Error ( Box < ErrorKind > ) ;
16
17
17
18
impl Error {
@@ -32,7 +33,7 @@ impl Error {
32
33
/// attribute makes sure clients don't count on exhaustive matching.
33
34
/// (Otherwise, adding a new variant could break existing code.)
34
35
#[ non_exhaustive]
35
- #[ derive( Debug ) ]
36
+ #[ derive( Clone , Debug ) ]
36
37
pub enum ErrorKind {
37
38
/// When a token doesn't have a valid JWT shape
38
39
InvalidToken ,
@@ -70,7 +71,7 @@ pub enum ErrorKind {
70
71
/// An error happened when decoding some base64 text
71
72
Base64 ( base64:: DecodeError ) ,
72
73
/// An error happened while serializing/deserializing JSON
73
- Json ( serde_json:: Error ) ,
74
+ Json ( Arc < serde_json:: Error > ) ,
74
75
/// Some of the text was invalid UTF-8
75
76
Utf8 ( :: std:: string:: FromUtf8Error ) ,
76
77
/// Something unspecified went wrong with crypto
@@ -144,7 +145,7 @@ impl From<base64::DecodeError> for Error {
144
145
145
146
impl From < serde_json:: Error > for Error {
146
147
fn from ( err : serde_json:: Error ) -> Error {
147
- new_error ( ErrorKind :: Json ( err) )
148
+ new_error ( ErrorKind :: Json ( Arc :: new ( err) ) )
148
149
}
149
150
}
150
151
0 commit comments