Skip to content

Commit

Permalink
chore: fix build service return code validation
Browse files Browse the repository at this point in the history
  • Loading branch information
naqvis committed May 21, 2024
1 parent 07b700f commit 538461b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/placeos-core/driver_manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,13 @@ module PlaceOS::Core
Log.debug { {message: "Invoked request: URI: #{link} . Server response: #{rep.status_code}", server_resp: rep.body} }
rep
end

raise "Returned invalid response code: #{resp.status_code}, #{link}, resp: #{resp.body}" unless resp.success? || resp.status_code == 303
task = JSON.parse(resp.body).as_h
break if task["state"] != "pending"
break if task["state"].in?("cancelled", "error", "done")
sleep 5
end
if resp.success? && task["state"] == "error"
if resp.success? && task["state"].in?("cancelled", "error")
raise task["message"].to_s
end
raise "Build API end-point #{link} returned invalid response code #{resp.status_code}, expected 303" unless resp.status_code == 303
Expand Down

0 comments on commit 538461b

Please sign in to comment.