Module: Gitlab::Metrics::Dashboard::Errors

Included in:
Metrics::Dashboard::BaseService
Defined in:
lib/gitlab/metrics/dashboard/errors.rb

Constant Summary collapse

DashboardProcessingError =
Class.new(StandardError)
PanelNotFoundError =
Class.new(StandardError)
MissingIntegrationError =
Class.new(StandardError)
LayoutError =
Class.new(DashboardProcessingError)
MissingQueryError =
Class.new(DashboardProcessingError)
NOT_FOUND_ERROR =
Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError

Instance Method Summary collapse

Instance Method Details

#handle_errors(error) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/gitlab/metrics/dashboard/errors.rb', line 18

def handle_errors(error)
  case error
  when DashboardProcessingError
    error(error.message, :unprocessable_entity)
  when NOT_FOUND_ERROR
    error(_("%{dashboard_path} could not be found.") % { dashboard_path: dashboard_path }, :not_found)
  when PanelNotFoundError
    error(error.message, :not_found)
  when ::Grafana::Client::Error
    error(error.message, :service_unavailable)
  when MissingIntegrationError
    error(_('Proxy support for this API is not available currently'), :bad_request)
  else
    raise error
  end
end

#panels_not_found!(opts) ⇒ Object

Raises:


35
36
37
# File 'lib/gitlab/metrics/dashboard/errors.rb', line 35

def panels_not_found!(opts)
  raise PanelNotFoundError.new(_("No panels matching properties %{opts}") % { opts: opts })
end