File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,19 @@ async fn orchestrator_post_request(
157157 url : & str ,
158158) -> Result < OrchestratorResponse , anyhow:: Error > {
159159 let client = reqwest:: Client :: new ( ) ;
160- let response = client. post ( url) . json ( & payload) . send ( ) ;
160+ let response = client. post ( url) . json ( & payload) . send ( ) . await ?;
161+ let status = response. status ( ) ;
162+ let text = response. text ( ) . await ?;
163+
164+ if !status. is_success ( ) {
165+ // Return the error with the status code and response body
166+ return Err ( anyhow:: anyhow!(
167+ "Orchestrator returned error status {}: {}" ,
168+ status,
169+ text
170+ ) ) ;
171+ }
161172
162- let json = response . await ? . json ( ) . await ?;
173+ let json: serde_json :: Value = serde_json :: from_str ( & text ) ?;
163174 Ok ( serde_json:: from_value ( json) . expect ( "unexpected json response from request" ) )
164175}
You can’t perform that action at this time.
0 commit comments