diff --git a/CHANGELOG.md b/CHANGELOG.md index b11070b..4595c08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## HEAD +- Any 404 when trying to delete an application will be considered duplicate (https://github.com/heroku/hatchet/pull/210) + ## 8.0.3 - Add support for Ruby 3.2 and 3.3 (https://github.com/heroku/hatchet/pull/203 and https://github.com/heroku/hatchet/pull/208) diff --git a/lib/hatchet/reaper.rb b/lib/hatchet/reaper.rb index 470519b..fc09e81 100644 --- a/lib/hatchet/reaper.rb +++ b/lib/hatchet/reaper.rb @@ -187,18 +187,10 @@ def destroy_with_log(name:, id:, reason: ) @api_rate_limit.call.app.delete(id) io.puts message - rescue Excon::Error::NotFound => e - body = e.response.body + rescue Excon::Error::NotFound, Excon::Error::Forbidden => e + status = e.response.status request_id = e.response.headers["Request-Id"] - if body =~ /Couldn\'t find that app./ - message = "Duplicate destroy attempted #{name.inspect}: #{id}, status: 404, request_id: #{request_id}" - raise AlreadyDeletedError.new(message) - else - raise e - end - rescue Excon::Error::Forbidden => e - request_id = e.response.headers["Request-Id"] - message = "Duplicate destroy attempted #{name.inspect}: #{id}, status: 403, request_id: #{request_id}" + message = "Possible duplicate destroy attempted #{name.inspect}: #{id}, status: #{status}, request_id: #{request_id}" raise AlreadyDeletedError.new(message) end end