File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -854,14 +854,31 @@ async fn check_response(
854854 . await
855855 . map_err ( Error :: Reqwest ) ?;
856856
857- let status = map[ "status" ] . as_str ( ) . unwrap ( ) ;
857+ let status = map
858+ . get ( "status" )
859+ . ok_or ( Error :: MissingField ) ?
860+ . as_str ( )
861+ . unwrap ( ) ;
858862
859863 match status {
860864 "success" => Ok ( map) ,
861- "error" => Err ( Error :: ResponseError ( ResponseError {
862- kind : map[ "errorType" ] . as_str ( ) . unwrap ( ) . to_string ( ) ,
863- message : map[ "error" ] . as_str ( ) . unwrap ( ) . to_string ( ) ,
864- } ) ) ,
865+ "error" => {
866+ let kind = map
867+ . get ( "errorType" )
868+ . ok_or ( Error :: MissingField ) ?
869+ . as_str ( )
870+ . unwrap ( )
871+ . to_string ( ) ;
872+
873+ let message = map
874+ . get ( "error" )
875+ . ok_or ( Error :: MissingField ) ?
876+ . as_str ( )
877+ . unwrap ( )
878+ . to_string ( ) ;
879+
880+ Err ( Error :: ResponseError ( ResponseError { kind, message } ) )
881+ }
865882 _ => Err ( Error :: UnknownResponseStatus ( UnknownResponseStatus (
866883 status. to_string ( ) ,
867884 ) ) ) ,
You can’t perform that action at this time.
0 commit comments