2020-11-27 13:09:52 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
##
|
|
|
|
# Abstract base class for CI/CD Quotas
|
|
|
|
#
|
|
|
|
class Limit
|
|
|
|
LimitExceededError = Class.new(StandardError)
|
|
|
|
|
|
|
|
def initialize(_context, _resource)
|
|
|
|
end
|
|
|
|
|
|
|
|
def enabled?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def exceeded?
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def message
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
|
|
|
|
|
|
|
def log_error!(extra_context = {})
|
2021-07-28 17:08:53 -04:00
|
|
|
::Gitlab::ErrorTracking.log_exception(limit_exceeded_error, extra_context)
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def limit_exceeded_error
|
|
|
|
LimitExceededError.new(message)
|
2020-11-27 13:09:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|