11use http:: StatusCode ;
22use http:: header:: { InvalidHeaderName , InvalidHeaderValue } ;
3- use serde:: Serialize ;
3+ use serde:: { Deserialize , Serialize } ;
44use thiserror:: Error ;
55
66use crate :: HtsGetError :: InternalError ;
@@ -30,18 +30,20 @@ pub enum HtsGetError {
3030 MethodNotAllowed ( String ) ,
3131 #[ error( "InternalError" ) ]
3232 InternalError ( String ) ,
33+ #[ error( "Wrapped" ) ]
34+ Wrapped ( WrappedHtsGetError , StatusCode ) ,
3335}
3436
3537/// A helper struct implementing [serde's Serialize trait](Serialize) to allow
3638/// easily converting HtsGetErrors to JSON
37- #[ derive( Serialize ) ]
39+ #[ derive( Serialize , Deserialize , Clone , Debug , Eq , PartialEq ) ]
3840pub struct JsonHtsGetError {
3941 error : String ,
4042 message : String ,
4143}
4244
4345/// The "htsget" container wrapping the actual error response above
44- #[ derive( Serialize ) ]
46+ #[ derive( Serialize , Deserialize , Clone , Debug , Eq , PartialEq ) ]
4547pub struct WrappedHtsGetError {
4648 htsget : JsonHtsGetError ,
4749}
@@ -60,6 +62,7 @@ impl HtsGetError {
6062 | HtsGetError :: InvalidRange ( err) => ( err, StatusCode :: BAD_REQUEST ) ,
6163 HtsGetError :: MethodNotAllowed ( err) => ( err, StatusCode :: METHOD_NOT_ALLOWED ) ,
6264 HtsGetError :: InternalError ( err) => ( err, StatusCode :: INTERNAL_SERVER_ERROR ) ,
65+ HtsGetError :: Wrapped ( err, status) => return ( err. clone ( ) , * status) ,
6366 } ;
6467
6568 (
0 commit comments