1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15- use rabbitmq_http_client:: error:: { ConversionError , Error as ApiClientError } ;
15+ use rabbitmq_http_client:: error:: { ConversionError , Error as ApiClientError , ErrorDetails } ;
1616use rabbitmq_http_client:: { blocking_api:: HttpClientError , responses:: HealthCheckFailureDetails } ;
17- use reqwest:: {
18- StatusCode ,
19- header:: { HeaderMap , InvalidHeaderValue } ,
20- } ;
17+ use reqwest:: StatusCode ;
18+ use reqwest:: header:: { HeaderMap , InvalidHeaderValue } ;
2119use std:: io;
2220use url:: Url ;
2321
@@ -65,15 +63,15 @@ pub enum CommandRunError {
6563 status_code : StatusCode ,
6664 url : Option < Url > ,
6765 body : Option < String > ,
68- error_details : Option < rabbitmq_http_client :: error :: ErrorDetails > ,
66+ error_details : Option < ErrorDetails > ,
6967 headers : Option < HeaderMap > ,
7068 } ,
7169 #[ error( "{}" , format_server_error( . status_code, . error_details) ) ]
7270 ServerError {
7371 status_code : StatusCode ,
7472 url : Option < Url > ,
7573 body : Option < String > ,
76- error_details : Option < rabbitmq_http_client :: error :: ErrorDetails > ,
74+ error_details : Option < ErrorDetails > ,
7775 headers : Option < HeaderMap > ,
7876 } ,
7977 #[ error( "Health check failed" ) ]
@@ -114,36 +112,32 @@ impl From<io::Error> for CommandRunError {
114112
115113impl From < HttpClientError > for CommandRunError {
116114 fn from ( value : HttpClientError ) -> Self {
117- use ApiClientError :: * ;
118115 match value {
119- UnsupportedArgumentValue { property } => Self :: UnsupportedArgumentValue { property } ,
120- ClientErrorResponse { status_code, url, body, error_details, headers, .. } => {
116+ ApiClientError :: UnsupportedArgumentValue { property } => Self :: UnsupportedArgumentValue { property } ,
117+ ApiClientError :: ClientErrorResponse { status_code, url, body, error_details, headers, .. } => {
121118 Self :: ClientError { status_code, url, body, error_details, headers }
122119 }
123- ServerErrorResponse { status_code, url, body, error_details, headers, .. } => {
120+ ApiClientError :: ServerErrorResponse { status_code, url, body, error_details, headers, .. } => {
124121 Self :: ServerError { status_code, url, body, error_details, headers }
125122 }
126- HealthCheckFailed { path, details, status_code } => {
123+ ApiClientError :: HealthCheckFailed { path, details, status_code } => {
127124 Self :: HealthCheckFailed { health_check_path : path, details, status_code }
128125 }
129- NotFound => Self :: NotFound ,
130- MultipleMatchingBindings => Self :: ConflictingOptions {
126+ ApiClientError :: NotFound => Self :: NotFound ,
127+ ApiClientError :: MultipleMatchingBindings => Self :: ConflictingOptions {
131128 message : "multiple bindings match, cannot determine which binding to delete without explicitly provided binding properties" . to_owned ( )
132129 } ,
133- InvalidHeaderValue { error } => Self :: InvalidHeaderValue { error } ,
134- RequestError { error, .. } => Self :: RequestError { error } ,
135- Other => Self :: Other ,
136- MissingProperty { argument } => Self :: MissingArgumentValue { property : argument } ,
137- IncompatibleBody { error, .. } => Self :: IncompatibleBody { error } ,
138- ParsingError { message } => Self :: FailureDuringExecution { message } ,
130+ ApiClientError :: InvalidHeaderValue { error } => Self :: InvalidHeaderValue { error } ,
131+ ApiClientError :: RequestError { error, .. } => Self :: RequestError { error } ,
132+ ApiClientError :: Other => Self :: Other ,
133+ ApiClientError :: MissingProperty { argument } => Self :: MissingArgumentValue { property : argument } ,
134+ ApiClientError :: IncompatibleBody { error, .. } => Self :: IncompatibleBody { error } ,
135+ ApiClientError :: ParsingError { message } => Self :: FailureDuringExecution { message } ,
139136 }
140137 }
141138}
142139
143- fn format_client_error (
144- status_code : & StatusCode ,
145- error_details : & Option < rabbitmq_http_client:: error:: ErrorDetails > ,
146- ) -> String {
140+ fn format_client_error ( status_code : & StatusCode , error_details : & Option < ErrorDetails > ) -> String {
147141 if let Some ( details) = error_details
148142 && let Some ( reason) = details. reason ( )
149143 {
@@ -155,10 +149,7 @@ fn format_client_error(
155149 )
156150}
157151
158- fn format_server_error (
159- status_code : & StatusCode ,
160- error_details : & Option < rabbitmq_http_client:: error:: ErrorDetails > ,
161- ) -> String {
152+ fn format_server_error ( status_code : & StatusCode , error_details : & Option < ErrorDetails > ) -> String {
162153 if let Some ( details) = error_details
163154 && let Some ( reason) = details. reason ( )
164155 {
0 commit comments