Skip to content

Commit

Permalink
Merge pull request #1313 from Shopify/give-concurrent-running-a-message
Browse files Browse the repository at this point in the history
Give `ConcurrentTaskRunning` a clear error message
  • Loading branch information
stephsachrajda authored Jul 14, 2023
2 parents 3121ad1 + 7e7c331 commit 764f2db
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/shipit/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def not_found(_error)
render(status: :not_found, json: { status: '404', error: 'Not Found' })
end

def conflict(_error)
render(status: :conflict, json: { status: '409', error: 'Conflict' })
def conflict(error)
render(status: :conflict, json: { status: '409', error: error.message })
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/models/shipit/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ module Shipit
class Task < Record
include DeferredTouch

ConcurrentTaskRunning = Class.new(StandardError)
class ConcurrentTaskRunning < StandardError
def message
"A task is already running."
end
end

PRESENCE_CHECK_TIMEOUT = 30
ACTIVE_STATUSES = %w(pending running aborting).freeze
Expand Down
1 change: 1 addition & 0 deletions test/controllers/api/deploys_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DeploysControllerTest < ApiControllerTestCase
end

assert_response :conflict
assert_json 'error', 'A task is already running.'
end

test "#create refuses to deploy unsuccessful commits if the require_ci flag is passed" do
Expand Down

0 comments on commit 764f2db

Please sign in to comment.