Commit 78ffbe8f authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'pl-rubocop-todo-rescue-standard-error' into 'master'

Resolves rubocop offense Style/RescueStandardError

See merge request gitlab-org/gitlab!57923
parents 706f11df e1acca6e
...@@ -893,13 +893,6 @@ Style/RedundantSelf: ...@@ -893,13 +893,6 @@ Style/RedundantSelf:
Style/RescueModifier: Style/RescueModifier:
Enabled: false Enabled: false
# Offense count: 359
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: implicit, explicit
Style/RescueStandardError:
Enabled: false
# Offense count: 123 # Offense count: 123
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/SingleArgumentDig: Style/SingleArgumentDig:
......
...@@ -97,7 +97,7 @@ class Import::BaseController < ApplicationController ...@@ -97,7 +97,7 @@ class Import::BaseController < ApplicationController
group = Groups::NestedCreateService.new(current_user, group_path: names).execute group = Groups::NestedCreateService.new(current_user, group_path: names).execute
group.errors.any? ? current_user.namespace : group group.errors.any? ? current_user.namespace : group
rescue => e rescue StandardError => e
Gitlab::AppLogger.error(e) Gitlab::AppLogger.error(e)
current_user.namespace current_user.namespace
......
...@@ -15,7 +15,7 @@ class Import::FogbugzController < Import::BaseController ...@@ -15,7 +15,7 @@ class Import::FogbugzController < Import::BaseController
def callback def callback
begin begin
res = Gitlab::FogbugzImport::Client.new(import_params.to_h.symbolize_keys) res = Gitlab::FogbugzImport::Client.new(import_params.to_h.symbolize_keys)
rescue rescue StandardError
# If the URI is invalid various errors can occur # If the URI is invalid various errors can occur
return redirect_to new_import_fogbugz_path, alert: _('Could not connect to FogBugz, check your URL') return redirect_to new_import_fogbugz_path, alert: _('Could not connect to FogBugz, check your URL')
end end
......
...@@ -24,7 +24,7 @@ class JiraConnect::ApplicationController < ApplicationController ...@@ -24,7 +24,7 @@ class JiraConnect::ApplicationController < ApplicationController
# Make sure `qsh` claim matches the current request # Make sure `qsh` claim matches the current request
render_403 unless payload['qsh'] == Atlassian::Jwt.create_query_string_hash(request.url, request.method, jira_connect_base_url) render_403 unless payload['qsh'] == Atlassian::Jwt.create_query_string_hash(request.url, request.method, jira_connect_base_url)
rescue rescue StandardError
render_403 render_403
end end
......
...@@ -35,7 +35,7 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -35,7 +35,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
return if archive_not_modified? return if archive_not_modified?
send_git_archive @repository, **repo_params send_git_archive @repository, **repo_params
rescue => ex rescue StandardError => ex
logger.error("#{self.class.name}: #{ex}") logger.error("#{self.class.name}: #{ex}")
git_not_found! git_not_found!
end end
......
...@@ -72,7 +72,7 @@ module ApplicationHelper ...@@ -72,7 +72,7 @@ module ApplicationHelper
else else
'Never' 'Never'
end end
rescue rescue StandardError
'Never' 'Never'
end end
......
...@@ -228,7 +228,7 @@ module EventsHelper ...@@ -228,7 +228,7 @@ module EventsHelper
def event_commit_title(message) def event_commit_title(message)
message ||= '' message ||= ''
(message.split("\n").first || "").truncate(70) (message.split("\n").first || "").truncate(70)
rescue rescue StandardError
"--broken encoding" "--broken encoding"
end end
......
...@@ -13,7 +13,7 @@ module X509Helper ...@@ -13,7 +13,7 @@ module X509Helper
end end
subjects subjects
rescue rescue StandardError
{} {}
end end
......
...@@ -33,7 +33,7 @@ module BlobViewer ...@@ -33,7 +33,7 @@ module BlobViewer
@json_data ||= begin @json_data ||= begin
prepare! prepare!
Gitlab::Json.parse(blob.data) Gitlab::Json.parse(blob.data)
rescue rescue StandardError
{} {}
end end
end end
......
...@@ -330,7 +330,7 @@ module Ci ...@@ -330,7 +330,7 @@ module Ci
begin begin
build.deployment.drop! build.deployment.drop!
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, build_id: build.id) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, build_id: build.id)
end end
......
...@@ -29,7 +29,7 @@ module Ci ...@@ -29,7 +29,7 @@ module Ci
def delete_file_from_storage def delete_file_from_storage
file.remove! file.remove!
true true
rescue => exception rescue StandardError => exception
Gitlab::ErrorTracking.track_exception(exception) Gitlab::ErrorTracking.track_exception(exception)
false false
end end
......
...@@ -15,13 +15,13 @@ module Ci ...@@ -15,13 +15,13 @@ module Ci
def exist? def exist?
ref_exists?(path) ref_exists?(path)
rescue rescue StandardError
false false
end end
def create def create
create_ref(sha, path) create_ref(sha, path)
rescue => e rescue StandardError => e
Gitlab::ErrorTracking Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id) .track_exception(e, pipeline_id: pipeline.id)
end end
...@@ -30,7 +30,7 @@ module Ci ...@@ -30,7 +30,7 @@ module Ci
delete_refs(path) delete_refs(path)
rescue Gitlab::Git::Repository::NoRepository rescue Gitlab::Git::Repository::NoRepository
# no-op # no-op
rescue => e rescue StandardError => e
Gitlab::ErrorTracking Gitlab::ErrorTracking
.track_exception(e, pipeline_id: pipeline.id) .track_exception(e, pipeline_id: pipeline.id)
end end
......
...@@ -53,7 +53,7 @@ module CacheableAttributes ...@@ -53,7 +53,7 @@ module CacheableAttributes
return cached_record if cached_record.present? return cached_record if cached_record.present?
current_without_cache.tap { |current_record| current_record&.cache! } current_without_cache.tap { |current_record| current_record&.cache! }
rescue => e rescue StandardError => e
if Rails.env.production? if Rails.env.production?
Gitlab::AppLogger.warn("Cached record for #{name} couldn't be loaded, falling back to uncached record: #{e}") Gitlab::AppLogger.warn("Cached record for #{name} couldn't be loaded, falling back to uncached record: #{e}")
else else
...@@ -66,7 +66,7 @@ module CacheableAttributes ...@@ -66,7 +66,7 @@ module CacheableAttributes
def expire def expire
Gitlab::SafeRequestStore.delete(request_store_cache_key) Gitlab::SafeRequestStore.delete(request_store_cache_key)
cache_backend.delete(cache_key) cache_backend.delete(cache_key)
rescue rescue StandardError
# Gracefully handle when Redis is not available. For example, # Gracefully handle when Redis is not available. For example,
# omnibus may fail here during gitlab:assets:compile. # omnibus may fail here during gitlab:assets:compile.
end end
......
...@@ -17,7 +17,7 @@ module HasRepository ...@@ -17,7 +17,7 @@ module HasRepository
def valid_repo? def valid_repo?
repository.exists? repository.exists?
rescue rescue StandardError
errors.add(:base, _('Invalid repository path')) errors.add(:base, _('Invalid repository path'))
false false
end end
...@@ -25,7 +25,7 @@ module HasRepository ...@@ -25,7 +25,7 @@ module HasRepository
def repo_exists? def repo_exists?
strong_memoize(:repo_exists) do strong_memoize(:repo_exists) do
repository.exists? repository.exists?
rescue rescue StandardError
false false
end end
end end
......
...@@ -50,7 +50,7 @@ module RepositoryStorageMovable ...@@ -50,7 +50,7 @@ module RepositoryStorageMovable
begin begin
storage_move.container.set_repository_read_only!(skip_git_transfer_check: true) storage_move.container.set_repository_read_only!(skip_git_transfer_check: true)
rescue => err rescue StandardError => err
storage_move.add_error(err.message) storage_move.add_error(err.message)
next false next false
end end
......
...@@ -33,7 +33,7 @@ module Sha256Attribute ...@@ -33,7 +33,7 @@ module Sha256Attribute
unless column.type == :binary unless column.type == :binary
raise ArgumentError.new("sha256_attribute #{name.inspect} is invalid since the column type is not :binary") raise ArgumentError.new("sha256_attribute #{name.inspect} is invalid since the column type is not :binary")
end end
rescue => error rescue StandardError => error
Gitlab::AppLogger.error "Sha256Attribute initialization: #{error.message}" Gitlab::AppLogger.error "Sha256Attribute initialization: #{error.message}"
raise raise
end end
......
...@@ -26,7 +26,7 @@ module ShaAttribute ...@@ -26,7 +26,7 @@ module ShaAttribute
unless column.type == :binary unless column.type == :binary
raise ArgumentError.new("sha_attribute #{name.inspect} is invalid since the column type is not :binary") raise ArgumentError.new("sha_attribute #{name.inspect} is invalid since the column type is not :binary")
end end
rescue => error rescue StandardError => error
Gitlab::AppLogger.error "ShaAttribute initialization: #{error.message}" Gitlab::AppLogger.error "ShaAttribute initialization: #{error.message}"
raise raise
end end
......
...@@ -48,7 +48,7 @@ module Storage ...@@ -48,7 +48,7 @@ module Storage
begin begin
send_update_instructions send_update_instructions
write_projects_repository_config write_projects_repository_config
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e, Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e,
full_path_before_last_save: full_path_before_last_save, full_path_before_last_save: full_path_before_last_save,
full_path: full_path, full_path: full_path,
......
...@@ -33,7 +33,7 @@ module X509SerialNumberAttribute ...@@ -33,7 +33,7 @@ module X509SerialNumberAttribute
unless column.type == :binary unless column.type == :binary
raise ArgumentError.new("x509_serial_number_attribute #{name.inspect} is invalid since the column type is not :binary") raise ArgumentError.new("x509_serial_number_attribute #{name.inspect} is invalid since the column type is not :binary")
end end
rescue => error rescue StandardError => error
Gitlab::AppLogger.error "X509SerialNumberAttribute initialization: #{error.message}" Gitlab::AppLogger.error "X509SerialNumberAttribute initialization: #{error.message}"
raise raise
end end
......
...@@ -94,7 +94,7 @@ module DesignManagement ...@@ -94,7 +94,7 @@ module DesignManagement
version version
end end
rescue rescue StandardError
raise CouldNotCreateVersion.new(sha, issue_id, design_actions) raise CouldNotCreateVersion.new(sha, issue_id, design_actions)
end end
......
...@@ -269,7 +269,7 @@ class Environment < ApplicationRecord ...@@ -269,7 +269,7 @@ class Environment < ApplicationRecord
Gitlab::OptimisticLocking.retry_lock(deployment.deployable, name: 'environment_cancel_deployment_jobs') do |deployable| Gitlab::OptimisticLocking.retry_lock(deployment.deployable, name: 'environment_cancel_deployment_jobs') do |deployable|
deployable.cancel! if deployable&.cancelable? deployable.cancel! if deployable&.cancelable?
end end
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, environment_id: id, deployment_id: deployment.id) Gitlab::ErrorTracking.track_exception(e, environment_id: id, deployment_id: deployment.id)
end end
end end
......
...@@ -69,7 +69,7 @@ class ProjectMember < Member ...@@ -69,7 +69,7 @@ class ProjectMember < Member
end end
true true
rescue rescue StandardError
false false
end end
......
...@@ -319,7 +319,7 @@ class Note < ApplicationRecord ...@@ -319,7 +319,7 @@ class Note < ApplicationRecord
return commit if for_commit? return commit if for_commit?
super super
rescue rescue StandardError
# Temp fix to prevent app crash # Temp fix to prevent app crash
# if note commit id doesn't exist # if note commit id doesn't exist
nil nil
......
...@@ -55,7 +55,7 @@ class PersonalAccessToken < ApplicationRecord ...@@ -55,7 +55,7 @@ class PersonalAccessToken < ApplicationRecord
begin begin
Gitlab::CryptoHelper.aes256_gcm_decrypt(encrypted_token) Gitlab::CryptoHelper.aes256_gcm_decrypt(encrypted_token)
rescue => ex rescue StandardError => ex
logger.warn "Failed to decrypt #{self.name} value stored in Redis for key ##{redis_key}: #{ex.class}" logger.warn "Failed to decrypt #{self.name} value stored in Redis for key ##{redis_key}: #{ex.class}"
encrypted_token encrypted_token
end end
......
...@@ -1097,7 +1097,7 @@ class Project < ApplicationRecord ...@@ -1097,7 +1097,7 @@ class Project < ApplicationRecord
else else
super super
end end
rescue rescue StandardError
super super
end end
...@@ -1559,7 +1559,7 @@ class Project < ApplicationRecord ...@@ -1559,7 +1559,7 @@ class Project < ApplicationRecord
repository.after_create repository.after_create
true true
rescue => err rescue StandardError => err
Gitlab::ErrorTracking.track_exception(err, project: { id: id, full_path: full_path, disk_path: disk_path }) Gitlab::ErrorTracking.track_exception(err, project: { id: id, full_path: full_path, disk_path: disk_path })
errors.add(:base, _('Failed to create repository')) errors.add(:base, _('Failed to create repository'))
false false
......
...@@ -98,7 +98,7 @@ class AsanaService < Service ...@@ -98,7 +98,7 @@ class AsanaService < Service
if tuple[0] if tuple[0]
task.update(completed: true) task.update(completed: true)
end end
rescue => e rescue StandardError => e
log_error(e.message) log_error(e.message)
next next
end end
......
...@@ -39,7 +39,7 @@ class ExternalWikiService < Service ...@@ -39,7 +39,7 @@ class ExternalWikiService < Service
def execute(_data) def execute(_data)
response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true) response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true)
response.body if response.code == 200 response.body if response.code == 200
rescue rescue StandardError
nil nil
end end
......
...@@ -103,7 +103,7 @@ class IrkerService < Service ...@@ -103,7 +103,7 @@ class IrkerService < Service
begin begin
new_recipient = URI.join(default_irc_uri, '/', recipient).to_s new_recipient = URI.join(default_irc_uri, '/', recipient).to_s
uri = consider_uri(URI.parse(new_recipient)) uri = consider_uri(URI.parse(new_recipient))
rescue rescue StandardError
log_error("Unable to create a valid URL", default_irc_uri: default_irc_uri, recipient: recipient) log_error("Unable to create a valid URL", default_irc_uri: default_irc_uri, recipient: recipient)
end end
end end
......
...@@ -305,7 +305,7 @@ class JiraService < IssueTrackerService ...@@ -305,7 +305,7 @@ class JiraService < IssueTrackerService
) )
true true
rescue => error rescue StandardError => error
log_error( log_error(
"Issue transition failed", "Issue transition failed",
error: { error: {
...@@ -490,7 +490,7 @@ class JiraService < IssueTrackerService ...@@ -490,7 +490,7 @@ class JiraService < IssueTrackerService
# Handle errors when doing Jira API calls # Handle errors when doing Jira API calls
def jira_request def jira_request
yield yield
rescue => error rescue StandardError => error
@error = error @error = error
log_error("Error sending message", client_url: client_url, error: @error.message) log_error("Error sending message", client_url: client_url, error: @error.message)
nil nil
......
...@@ -130,7 +130,7 @@ class ProjectTeam ...@@ -130,7 +130,7 @@ class ProjectTeam
end end
true true
rescue rescue StandardError
false false
end end
......
...@@ -32,7 +32,7 @@ class ReleaseHighlight ...@@ -32,7 +32,7 @@ class ReleaseHighlight
begin begin
item.tap {|i| i['body'] = Kramdown::Document.new(i['body']).to_html } item.tap {|i| i['body'] = Kramdown::Document.new(i['body']).to_html }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, file_path: file_path) Gitlab::ErrorTracking.track_exception(e, file_path: file_path)
next next
......
...@@ -214,7 +214,7 @@ class RemoteMirror < ApplicationRecord ...@@ -214,7 +214,7 @@ class RemoteMirror < ApplicationRecord
if super if super
Gitlab::UrlSanitizer.new(super, credentials: credentials).full_url Gitlab::UrlSanitizer.new(super, credentials: credentials).full_url
end end
rescue rescue StandardError
super super
end end
...@@ -275,7 +275,7 @@ class RemoteMirror < ApplicationRecord ...@@ -275,7 +275,7 @@ class RemoteMirror < ApplicationRecord
return url unless ssh_key_auth? && password.present? return url unless ssh_key_auth? && password.present?
Gitlab::UrlSanitizer.new(read_attribute(:url), credentials: { user: user }).full_url Gitlab::UrlSanitizer.new(read_attribute(:url), credentials: { user: user }).full_url
rescue rescue StandardError
super super
end end
......
...@@ -34,7 +34,7 @@ module Storage ...@@ -34,7 +34,7 @@ module Storage
begin begin
gitlab_shell.mv_repository(repository_storage, "#{old_full_path}.wiki", "#{new_full_path}.wiki") gitlab_shell.mv_repository(repository_storage, "#{old_full_path}.wiki", "#{new_full_path}.wiki")
return true return true
rescue => e rescue StandardError => e
Gitlab::AppLogger.error("Exception renaming #{old_full_path} -> #{new_full_path}: #{e}") Gitlab::AppLogger.error("Exception renaming #{old_full_path} -> #{new_full_path}: #{e}")
# Returning false does not rollback after_* transaction but gives # Returning false does not rollback after_* transaction but gives
# us information about failing some of tasks # us information about failing some of tasks
......
...@@ -88,7 +88,7 @@ class Wiki ...@@ -88,7 +88,7 @@ class Wiki
repository.create_if_not_exists repository.create_if_not_exists
raise CouldNotCreateWikiError unless repository_exists? raise CouldNotCreateWikiError unless repository_exists?
rescue => err rescue StandardError => err
Gitlab::ErrorTracking.track_exception(err, wiki: { Gitlab::ErrorTracking.track_exception(err, wiki: {
container_type: container.class.name, container_type: container.class.name,
container_id: container.id, container_id: container.id,
......
...@@ -131,7 +131,7 @@ class AuditEventService ...@@ -131,7 +131,7 @@ class AuditEventService
def save_or_track(event) def save_or_track(event)
event.save! event.save!
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, audit_event_type: event.class.to_s) Gitlab::ErrorTracking.track_exception(e, audit_event_type: event.class.to_s)
end end
end end
......
...@@ -15,7 +15,7 @@ module AutoMerge ...@@ -15,7 +15,7 @@ module AutoMerge
AutoMergeProcessWorker.perform_async(merge_request.id) AutoMergeProcessWorker.perform_async(merge_request.id)
strategy.to_sym strategy.to_sym
rescue => e rescue StandardError => e
track_exception(e, merge_request) track_exception(e, merge_request)
:failed :failed
end end
...@@ -35,7 +35,7 @@ module AutoMerge ...@@ -35,7 +35,7 @@ module AutoMerge
end end
success success
rescue => e rescue StandardError => e
track_exception(e, merge_request) track_exception(e, merge_request)
error("Can't cancel the automatic merge", 406) error("Can't cancel the automatic merge", 406)
end end
...@@ -47,7 +47,7 @@ module AutoMerge ...@@ -47,7 +47,7 @@ module AutoMerge
end end
success success
rescue => e rescue StandardError => e
track_exception(e, merge_request) track_exception(e, merge_request)
error("Can't abort the automatic merge", 406) error("Can't abort the automatic merge", 406)
end end
......
...@@ -24,7 +24,7 @@ module Ci ...@@ -24,7 +24,7 @@ module Ci
end end
rescue ::Gitlab::Ci::Trace::AlreadyArchivedError rescue ::Gitlab::Ci::Trace::AlreadyArchivedError
# It's already archived, thus we can safely ignore this exception. # It's already archived, thus we can safely ignore this exception.
rescue => e rescue StandardError => e
# Tracks this error with application logs, Sentry, and Prometheus. # Tracks this error with application logs, Sentry, and Prometheus.
# If `archive!` keeps failing for over a week, that could incur data loss. # If `archive!` keeps failing for over a week, that could incur data loss.
# (See more https://docs.gitlab.com/ee/administration/job_logs.html#new-incremental-logging-architecture) # (See more https://docs.gitlab.com/ee/administration/job_logs.html#new-incremental-logging-architecture)
......
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
key: key(base_pipeline, head_pipeline), key: key(base_pipeline, head_pipeline),
data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_quality_mr_diff).present.for_files(merge_request.new_paths) data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_quality_mr_diff).present.for_files(merge_request.new_paths)
} }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
{ {
status: :error, status: :error,
......
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
key: key(base_pipeline, head_pipeline), key: key(base_pipeline, head_pipeline),
data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_coverage).present.for_files(merge_request.new_paths) data: head_pipeline.pipeline_artifacts.find_by_file_type(:code_coverage).present.for_files(merge_request.new_paths)
} }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception( Gitlab::ErrorTracking.track_exception(
e, e,
project_id: project.id, project_id: project.id,
......
...@@ -14,7 +14,7 @@ module Ci ...@@ -14,7 +14,7 @@ module Ci
key: key(base_pipeline, head_pipeline), key: key(base_pipeline, head_pipeline),
data: data data: data
} }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
{ {
status: :error, status: :error,
......
...@@ -13,7 +13,7 @@ module Ci ...@@ -13,7 +13,7 @@ module Ci
key: key(base_pipeline, head_pipeline), key: key(base_pipeline, head_pipeline),
data: head_pipeline.terraform_reports.plans data: head_pipeline.terraform_reports.plans
} }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, project_id: project.id) Gitlab::ErrorTracking.track_exception(e, project_id: project.id)
{ {
status: :error, status: :error,
......
...@@ -136,7 +136,7 @@ module Ci ...@@ -136,7 +136,7 @@ module Ci
rescue *OBJECT_STORAGE_ERRORS => error rescue *OBJECT_STORAGE_ERRORS => error
track_exception(error, params) track_exception(error, params)
error(error.message, :service_unavailable) error(error.message, :service_unavailable)
rescue => error rescue StandardError => error
track_exception(error, params) track_exception(error, params)
error(error.message, :bad_request) error(error.message, :bad_request)
end end
......
...@@ -12,7 +12,7 @@ module Ci ...@@ -12,7 +12,7 @@ module Ci
prerequisites.each(&:complete!) prerequisites.each(&:complete!)
build.enqueue_preparing! build.enqueue_preparing!
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, build_id: build.id) Gitlab::ErrorTracking.track_exception(e, build_id: build.id)
build.drop(:unmet_prerequisites) build.drop(:unmet_prerequisites)
......
...@@ -169,7 +169,7 @@ module Ci ...@@ -169,7 +169,7 @@ module Ci
@metrics.increment_queue_operation(:build_conflict_transition) @metrics.increment_queue_operation(:build_conflict_transition)
Result.new(nil, nil, false) Result.new(nil, nil, false)
rescue => ex rescue StandardError => ex
@metrics.increment_queue_operation(:build_conflict_exception) @metrics.increment_queue_operation(:build_conflict_exception)
# If an error (e.g. GRPC::DeadlineExceeded) occurred constructing # If an error (e.g. GRPC::DeadlineExceeded) occurred constructing
...@@ -233,7 +233,7 @@ module Ci ...@@ -233,7 +233,7 @@ module Ci
Gitlab::OptimisticLocking.retry_lock(build, 3, name: 'register_job_scheduler_failure') do |subject| Gitlab::OptimisticLocking.retry_lock(build, 3, name: 'register_job_scheduler_failure') do |subject|
subject.drop!(:scheduler_failure) subject.drop!(:scheduler_failure)
end end
rescue => ex rescue StandardError => ex
build.doom! build.doom!
# This requires extra exception, otherwise we would loose information # This requires extra exception, otherwise we would loose information
......
...@@ -27,7 +27,7 @@ module Ci ...@@ -27,7 +27,7 @@ module Ci
stop_actions.each do |stop_action| stop_actions.each do |stop_action|
stop_action.play(stop_action.user) stop_action.play(stop_action.user)
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, deployable_id: stop_action.id) Gitlab::ErrorTracking.track_exception(e, deployable_id: stop_action.id)
end end
end end
......
...@@ -51,7 +51,7 @@ module Clusters ...@@ -51,7 +51,7 @@ module Clusters
def remove_pod def remove_pod
helm_api.delete_pod!(pod_name) helm_api.delete_pod!(pod_name)
rescue rescue StandardError
# no-op # no-op
end end
......
...@@ -19,7 +19,7 @@ module ContainerExpirationPolicies ...@@ -19,7 +19,7 @@ module ContainerExpirationPolicies
service_result = Projects::ContainerRepository::CleanupTagsService service_result = Projects::ContainerRepository::CleanupTagsService
.new(project, nil, policy_params.merge('container_expiration_policy' => true)) .new(project, nil, policy_params.merge('container_expiration_policy' => true))
.execute(repository) .execute(repository)
rescue rescue StandardError
repository.cleanup_unfinished! repository.cleanup_unfinished!
raise raise
......
...@@ -15,7 +15,7 @@ module Deployments ...@@ -15,7 +15,7 @@ module Deployments
Gitlab::OptimisticLocking.retry_lock(older_deployment.deployable, name: 'older_deployments_drop') do |deployable| Gitlab::OptimisticLocking.retry_lock(older_deployment.deployable, name: 'older_deployments_drop') do |deployable|
deployable.drop(:forward_deployment_failure) deployable.drop(:forward_deployment_failure)
end end
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, subject_id: @deployment.id, deployment_id: older_deployment.id) Gitlab::ErrorTracking.track_exception(e, subject_id: @deployment.id, deployment_id: older_deployment.id)
end end
end end
......
...@@ -47,7 +47,7 @@ module DesignManagement ...@@ -47,7 +47,7 @@ module DesignManagement
end end
ServiceResponse.success ServiceResponse.success
rescue => error rescue StandardError => error
log_exception(error) log_exception(error)
target_design_collection.error_copy! target_design_collection.error_copy!
......
...@@ -10,7 +10,7 @@ module Ide ...@@ -10,7 +10,7 @@ module Ide
def execute def execute
schema = predefined_schema_for(params[:filename]) || {} schema = predefined_schema_for(params[:filename]) || {}
success(schema: schema) success(schema: schema)
rescue => e rescue StandardError => e
error(e.message) error(e.message)
end end
......
...@@ -18,7 +18,7 @@ module Import ...@@ -18,7 +18,7 @@ module Import
group = Groups::NestedCreateService.new(current_user, group_path: namespace).execute group = Groups::NestedCreateService.new(current_user, group_path: namespace).execute
group.errors.any? ? current_user.namespace : group group.errors.any? ? current_user.namespace : group
rescue => e rescue StandardError => e
Gitlab::AppLogger.error(e) Gitlab::AppLogger.error(e)
current_user.namespace current_user.namespace
......
...@@ -41,7 +41,7 @@ module JiraImport ...@@ -41,7 +41,7 @@ module JiraImport
project.save! && jira_import.schedule! project.save! && jira_import.schedule!
ServiceResponse.success(payload: { import_data: jira_import } ) ServiceResponse.success(payload: { import_data: jira_import } )
rescue => ex rescue StandardError => ex
# in case project.save! raises an error # in case project.save! raises an error
Gitlab::ErrorTracking.track_exception(ex, project_id: project.id) Gitlab::ErrorTracking.track_exception(ex, project_id: project.id)
jira_import&.do_fail!(error_message: ex.message) jira_import&.do_fail!(error_message: ex.message)
......
...@@ -12,7 +12,7 @@ module Lfs ...@@ -12,7 +12,7 @@ module Lfs
error('already locked', 409, current_lock) error('already locked', 409, current_lock)
rescue Gitlab::GitAccess::ForbiddenError => ex rescue Gitlab::GitAccess::ForbiddenError => ex
error(ex.message, 403) error(ex.message, 403)
rescue => ex rescue StandardError => ex
error(ex.message, 500) error(ex.message, 500)
end end
......
...@@ -4,7 +4,7 @@ module Lfs ...@@ -4,7 +4,7 @@ module Lfs
class LocksFinderService < BaseService class LocksFinderService < BaseService
def execute def execute
success(locks: find_locks) success(locks: find_locks)
rescue => ex rescue StandardError => ex
error(ex.message, 500) error(ex.message, 500)
end end
......
...@@ -16,7 +16,7 @@ module Lfs ...@@ -16,7 +16,7 @@ module Lfs
end end
success success
rescue => err rescue StandardError => err
Gitlab::ErrorTracking.log_exception(err, extra_context) Gitlab::ErrorTracking.log_exception(err, extra_context)
error(err.message) error(err.message)
end end
......
...@@ -12,7 +12,7 @@ module Lfs ...@@ -12,7 +12,7 @@ module Lfs
error(ex.message, 403) error(ex.message, 403)
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
error(_('Lock not found'), 404) error(_('Lock not found'), 404)
rescue => ex rescue StandardError => ex
error(ex.message, 500) error(ex.message, 500)
end end
......
...@@ -96,7 +96,7 @@ module MergeRequests ...@@ -96,7 +96,7 @@ module MergeRequests
rescue Gitlab::Git::PreReceiveError => e rescue Gitlab::Git::PreReceiveError => e
raise MergeError, raise MergeError,
"Something went wrong during merge pre-receive hook. #{e.message}".strip "Something went wrong during merge pre-receive hook. #{e.message}".strip
rescue => e rescue StandardError => e
handle_merge_error(log_message: e.message) handle_merge_error(log_message: e.message)
raise_error(GENERIC_ERROR_MESSAGE) raise_error(GENERIC_ERROR_MESSAGE)
end end
......
...@@ -27,7 +27,7 @@ module MergeRequests ...@@ -27,7 +27,7 @@ module MergeRequests
repository.rebase(current_user, merge_request, skip_ci: @skip_ci) repository.rebase(current_user, merge_request, skip_ci: @skip_ci)
true true
rescue => e rescue StandardError => e
log_error(exception: e, message: REBASE_ERROR, save_message_on_model: true) log_error(exception: e, message: REBASE_ERROR, save_message_on_model: true)
false false
......
...@@ -213,7 +213,7 @@ module MergeRequests ...@@ -213,7 +213,7 @@ module MergeRequests
# If the a commit no longer exists in this repo, gitlab_git throws # If the a commit no longer exists in this repo, gitlab_git throws
# a Rugged::OdbError. This is fixed in https://gitlab.com/gitlab-org/gitlab_git/merge_requests/52 # a Rugged::OdbError. This is fixed in https://gitlab.com/gitlab-org/gitlab_git/merge_requests/52
@commits = @project.repository.commits_between(common_ref, @push.newrev) if common_ref @commits = @project.repository.commits_between(common_ref, @push.newrev) if common_ref
rescue rescue StandardError
end end
elsif @push.branch_removed? elsif @push.branch_removed?
# No commits for a deleted branch. # No commits for a deleted branch.
......
...@@ -29,7 +29,7 @@ module MergeRequests ...@@ -29,7 +29,7 @@ module MergeRequests
squash_sha = repository.squash(current_user, merge_request, message || merge_request.default_squash_commit_message) squash_sha = repository.squash(current_user, merge_request, message || merge_request.default_squash_commit_message)
success(squash_sha: squash_sha) success(squash_sha: squash_sha)
rescue => e rescue StandardError => e
log_error(exception: e, message: 'Failed to squash merge request') log_error(exception: e, message: 'Failed to squash merge request')
false false
...@@ -37,7 +37,7 @@ module MergeRequests ...@@ -37,7 +37,7 @@ module MergeRequests
def squash_in_progress? def squash_in_progress?
merge_request.squash_in_progress? merge_request.squash_in_progress?
rescue => e rescue StandardError => e
log_error(exception: e, message: 'Failed to check squash in progress') log_error(exception: e, message: 'Failed to check squash in progress')
raise SquashInProgressError, e.message raise SquashInProgressError, e.message
......
...@@ -45,7 +45,7 @@ module Packages ...@@ -45,7 +45,7 @@ module Packages
::Packages::UpdateTagsService ::Packages::UpdateTagsService
.new(package, package_tags) .new(package, package_tags)
.execute .execute
rescue => e rescue StandardError => e
raise InvalidMetadataError, e.message raise InvalidMetadataError, e.message
end end
......
...@@ -106,7 +106,7 @@ module Packages ...@@ -106,7 +106,7 @@ module Packages
Packages::PackageFile.find(package_file.id).file.use_file do |file_path| Packages::PackageFile.find(package_file.id).file.use_file do |file_path|
Gem::Package.new(File.open(file_path)) Gem::Package.new(File.open(file_path))
end end
rescue rescue StandardError
raise ExtractionError.new('Unable to read gem file') raise ExtractionError.new('Unable to read gem file')
end end
......
...@@ -59,7 +59,7 @@ module Pages ...@@ -59,7 +59,7 @@ module Pages
end end
@logger.info(message: "Pages legacy storage migration: batch processed", migrated: @migrated, errored: @errored) @logger.info(message: "Pages legacy storage migration: batch processed", migrated: @migrated, errored: @errored)
rescue => e rescue StandardError => e
# This method should never raise exception otherwise all threads might be killed # This method should never raise exception otherwise all threads might be killed
# and this will result in queue starving (and deadlock) # and this will result in queue starving (and deadlock)
Gitlab::ErrorTracking.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
...@@ -81,7 +81,7 @@ module Pages ...@@ -81,7 +81,7 @@ module Pages
@logger.error(message: "Pages legacy storage migration: project failed to be migrated: #{result[:message]}", project_id: project.id, pages_path: project.pages_path, duration: time.round(2)) @logger.error(message: "Pages legacy storage migration: project failed to be migrated: #{result[:message]}", project_id: project.id, pages_path: project.pages_path, duration: time.round(2))
@counters_lock.synchronize { @errored += 1 } @counters_lock.synchronize { @errored += 1 }
end end
rescue => e rescue StandardError => e
@counters_lock.synchronize { @errored += 1 } @counters_lock.synchronize { @errored += 1 }
@logger.error(message: "Pages legacy storage migration: project failed to be migrated: #{result[:message]}", project_id: project&.id, pages_path: project&.pages_path) @logger.error(message: "Pages legacy storage migration: project failed to be migrated: #{result[:message]}", project_id: project&.id, pages_path: project&.pages_path)
Gitlab::ErrorTracking.track_exception(e, project_id: project&.id) Gitlab::ErrorTracking.track_exception(e, project_id: project&.id)
......
...@@ -31,7 +31,7 @@ module Pages ...@@ -31,7 +31,7 @@ module Pages
end end
success(archive_path: output_file, entries_count: entries_count) success(archive_path: output_file, entries_count: entries_count)
rescue => e rescue StandardError => e
FileUtils.rm_f(output_file) if output_file FileUtils.rm_f(output_file) if output_file
raise e raise e
end end
......
...@@ -66,7 +66,7 @@ module PagesDomains ...@@ -66,7 +66,7 @@ module PagesDomains
project_id: pages_domain.project_id, project_id: pages_domain.project_id,
pages_domain: pages_domain.domain pages_domain: pages_domain.domain
) )
rescue => e rescue StandardError => e
# getting authorizations is an additional network request which can raise errors # getting authorizations is an additional network request which can raise errors
Gitlab::ErrorTracking.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
end end
......
...@@ -72,7 +72,7 @@ module Projects ...@@ -72,7 +72,7 @@ module Projects
rescue ActiveRecord::RecordInvalid => e rescue ActiveRecord::RecordInvalid => e
message = "Unable to save #{e.inspect}: #{e.record.errors.full_messages.join(", ")}" message = "Unable to save #{e.inspect}: #{e.record.errors.full_messages.join(", ")}"
fail(error: message) fail(error: message)
rescue => e rescue StandardError => e
@project.errors.add(:base, e.message) if @project @project.errors.add(:base, e.message) if @project
fail(error: e.message) fail(error: e.message)
end end
......
...@@ -41,7 +41,7 @@ module Projects ...@@ -41,7 +41,7 @@ module Projects
current_user.invalidate_personal_projects_count current_user.invalidate_personal_projects_count
true true
rescue => error rescue StandardError => error
attempt_rollback(project, error.message) attempt_rollback(project, error.message)
false false
rescue Exception => error # rubocop:disable Lint/RescueException rescue Exception => error # rubocop:disable Lint/RescueException
......
...@@ -29,7 +29,7 @@ module Projects ...@@ -29,7 +29,7 @@ module Projects
Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type) Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)
error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message }) error(s_("ImportProjects|Error importing repository %{project_safe_import_url} into %{project_full_path} - %{message}") % { project_safe_import_url: project.safe_import_url, project_full_path: project.full_path, message: e.message })
rescue => e rescue StandardError => e
message = Projects::ImportErrorFilter.filter_message(e.message) message = Projects::ImportErrorFilter.filter_message(e.message)
Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type) Gitlab::ErrorTracking.track_exception(e, project_path: project.full_path, importer: project.import_type)
......
...@@ -16,7 +16,7 @@ module Projects ...@@ -16,7 +16,7 @@ module Projects
end end
success success
rescue => e rescue StandardError => e
error(e.message) error(e.message)
end end
end end
......
...@@ -102,7 +102,7 @@ module Projects ...@@ -102,7 +102,7 @@ module Projects
File.open(file, 'r') do |f| File.open(file, 'r') do |f|
f.read f.read
end end
rescue rescue StandardError
nil nil
end end
end end
......
...@@ -48,7 +48,7 @@ module Projects ...@@ -48,7 +48,7 @@ module Projects
end end
rescue InvalidStateError => e rescue InvalidStateError => e
error(e.message) error(e.message)
rescue => e rescue StandardError => e
error(e.message) error(e.message)
raise e raise e
end end
...@@ -145,7 +145,7 @@ module Projects ...@@ -145,7 +145,7 @@ module Projects
FileUtils.mkdir_p(pages_path) FileUtils.mkdir_p(pages_path)
begin begin
FileUtils.move(public_path, previous_public_path) FileUtils.move(public_path, previous_public_path)
rescue rescue StandardError
end end
FileUtils.move(archive_public_path, public_path) FileUtils.move(archive_public_path, public_path)
ensure ensure
......
...@@ -24,7 +24,7 @@ module Projects ...@@ -24,7 +24,7 @@ module Projects
hard_retry_or_fail(remote_mirror, e.message, tries) hard_retry_or_fail(remote_mirror, e.message, tries)
error(e.message) error(e.message)
rescue => e rescue StandardError => e
remote_mirror.hard_fail!(e.message) remote_mirror.hard_fail!(e.message)
raise e raise e
end end
......
...@@ -57,7 +57,7 @@ module Releases ...@@ -57,7 +57,7 @@ module Releases
create_evidence!(release, evidence_pipeline) create_evidence!(release, evidence_pipeline)
success(tag: tag, release: release) success(tag: tag, release: release)
rescue => e rescue StandardError => e
error(e.message, 400) error(e.message, 400)
end end
......
...@@ -27,7 +27,7 @@ module Snippets ...@@ -27,7 +27,7 @@ module Snippets
rescue DeleteRepositoryError rescue DeleteRepositoryError
attempt_rollback_repositories attempt_rollback_repositories
service_response_error('Failed to delete snippet repositories.', 400) service_response_error('Failed to delete snippet repositories.', 400)
rescue rescue StandardError
# In case the delete operation fails # In case the delete operation fails
attempt_rollback_repositories attempt_rollback_repositories
service_response_error('Failed to remove snippets.', 400) service_response_error('Failed to remove snippets.', 400)
......
...@@ -69,7 +69,7 @@ module Snippets ...@@ -69,7 +69,7 @@ module Snippets
end end
snippet_saved snippet_saved
rescue => e # Rescuing all because we can receive Creation exceptions, GRPC exceptions, Git exceptions, ... rescue StandardError => e # Rescuing all because we can receive Creation exceptions, GRPC exceptions, Git exceptions, ...
Gitlab::ErrorTracking.log_exception(e, service: 'Snippets::CreateService') Gitlab::ErrorTracking.log_exception(e, service: 'Snippets::CreateService')
# If the commit action failed we need to remove the repository if exists # If the commit action failed we need to remove the repository if exists
......
...@@ -30,7 +30,7 @@ module Snippets ...@@ -30,7 +30,7 @@ module Snippets
ServiceResponse.success(message: 'Snippet was deleted.') ServiceResponse.success(message: 'Snippet was deleted.')
rescue DestroyError rescue DestroyError
service_response_error('Failed to remove snippet repository.', 400) service_response_error('Failed to remove snippet repository.', 400)
rescue rescue StandardError
attempt_rollback_repository attempt_rollback_repository
service_response_error('Failed to remove snippet.', 400) service_response_error('Failed to remove snippet.', 400)
end end
......
...@@ -78,7 +78,7 @@ module Snippets ...@@ -78,7 +78,7 @@ module Snippets
create_commit(snippet) create_commit(snippet)
true true
rescue => e rescue StandardError => e
# Restore old attributes but re-assign changes so they're not lost # Restore old attributes but re-assign changes so they're not lost
unless snippet.previous_changes.empty? unless snippet.previous_changes.empty?
snippet.previous_changes.each { |attr, value| snippet[attr] = value[0] } snippet.previous_changes.each { |attr, value| snippet[attr] = value[0] }
......
...@@ -26,7 +26,7 @@ module Spam ...@@ -26,7 +26,7 @@ module Spam
begin begin
is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params) is_spam, is_blatant = akismet_client.check(options[:ip_address], options[:user_agent], params)
is_spam || is_blatant is_spam || is_blatant
rescue => e rescue StandardError => e
Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping check") Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping check")
false false
end end
...@@ -66,7 +66,7 @@ module Spam ...@@ -66,7 +66,7 @@ module Spam
begin begin
akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend akismet_client.public_send(type, options[:ip_address], options[:user_agent], params) # rubocop:disable GitlabSecurity/PublicSend
true true
rescue => e rescue StandardError => e
Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping!") Gitlab::AppLogger.error("Unable to connect to Akismet: #{e}, skipping!")
false false
end end
......
...@@ -58,7 +58,7 @@ module Spam ...@@ -58,7 +58,7 @@ module Spam
# @TODO: log error via try_post https://gitlab.com/gitlab-org/gitlab/-/issues/219223 # @TODO: log error via try_post https://gitlab.com/gitlab-org/gitlab/-/issues/219223
Gitlab::ErrorTracking.log_exception(e) Gitlab::ErrorTracking.log_exception(e)
nil nil
rescue rescue StandardError
# @TODO log # @TODO log
ALLOW ALLOW
end end
......
...@@ -25,7 +25,7 @@ module StaticSiteEditor ...@@ -25,7 +25,7 @@ module StaticSiteEditor
ServiceResponse.success(payload: data) ServiceResponse.success(payload: data)
rescue ValidationError => e rescue ValidationError => e
ServiceResponse.error(message: e.message) ServiceResponse.error(message: e.message)
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_and_raise_exception(e) Gitlab::ErrorTracking.track_and_raise_exception(e)
end end
......
...@@ -90,7 +90,7 @@ class VerifyPagesDomainService < BaseService ...@@ -90,7 +90,7 @@ class VerifyPagesDomainService < BaseService
records.any? do |record| records.any? do |record|
record == domain.keyed_verification_code || record == domain.verification_code record == domain.keyed_verification_code || record == domain.verification_code
end end
rescue => err rescue StandardError => err
log_error("Failed to check TXT records on #{domain_name} for #{domain.domain}: #{err}") log_error("Failed to check TXT records on #{domain_name} for #{domain.domain}: #{err}")
false false
end end
......
...@@ -54,7 +54,7 @@ class FileMover ...@@ -54,7 +54,7 @@ class FileMover
updated_text = to_model.read_attribute(update_field) updated_text = to_model.read_attribute(update_field)
.gsub(temp_file_uploader.markdown_link, uploader.markdown_link) .gsub(temp_file_uploader.markdown_link, uploader.markdown_link)
to_model.update_attribute(update_field, updated_text) to_model.update_attribute(update_field, updated_text)
rescue rescue StandardError
revert revert
false false
end end
......
...@@ -483,7 +483,7 @@ module ObjectStorage ...@@ -483,7 +483,7 @@ module ObjectStorage
end end
file file
rescue => e rescue StandardError => e
# in case of failure delete new file # in case of failure delete new file
new_file.delete unless new_file.nil? new_file.delete unless new_file.nil?
# revert back to the old file # revert back to the old file
......
...@@ -29,7 +29,7 @@ class BulkImportWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -29,7 +29,7 @@ class BulkImportWorker # rubocop:disable Scalability/IdempotentWorker
end end
re_enqueue re_enqueue
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e, bulk_import_id: @bulk_import&.id) Gitlab::ErrorTracking.track_exception(e, bulk_import_id: @bulk_import&.id)
@bulk_import&.fail_op @bulk_import&.fail_op
......
...@@ -26,7 +26,7 @@ module BulkImports ...@@ -26,7 +26,7 @@ module BulkImports
entity_id entity_id
) )
end end
rescue => e rescue StandardError => e
logger.error( logger.error(
worker: self.class.name, worker: self.class.name,
entity_id: entity_id, entity_id: entity_id,
......
...@@ -46,7 +46,7 @@ module BulkImports ...@@ -46,7 +46,7 @@ module BulkImports
pipeline_tracker.pipeline_class.new(context).run pipeline_tracker.pipeline_class.new(context).run
pipeline_tracker.finish! pipeline_tracker.finish!
rescue => e rescue StandardError => e
pipeline_tracker.fail_op! pipeline_tracker.fail_op!
logger.error( logger.error(
......
...@@ -32,7 +32,7 @@ module Gitlab ...@@ -32,7 +32,7 @@ module Gitlab
counter.increment counter.increment
info(project.id, message: 'importer finished') info(project.id, message: 'importer finished')
rescue => e rescue StandardError => e
error(project.id, e) error(project.id, e)
end end
......
...@@ -14,7 +14,7 @@ module Gitlab ...@@ -14,7 +14,7 @@ module Gitlab
try_import(client, project) try_import(client, project)
info(project_id, message: 'stage finished') info(project_id, message: 'stage finished')
rescue => e rescue StandardError => e
error(project_id, e) error(project_id, e)
end end
......
...@@ -69,7 +69,7 @@ module LimitedCapacity ...@@ -69,7 +69,7 @@ module LimitedCapacity
job_tracker.register(jid) job_tracker.register(jid)
report_running_jobs_metrics report_running_jobs_metrics
perform_work(*args) perform_work(*args)
rescue => exception rescue StandardError => exception
raise raise
ensure ensure
job_tracker.remove(jid) job_tracker.remove(jid)
......
...@@ -33,7 +33,7 @@ module WaitableWorker ...@@ -33,7 +33,7 @@ module WaitableWorker
args_list.each do |args| args_list.each do |args|
new.perform(*args) new.perform(*args)
rescue rescue StandardError
failed << args failed << args
end end
......
...@@ -36,7 +36,7 @@ class CreateCommitSignatureWorker ...@@ -36,7 +36,7 @@ class CreateCommitSignatureWorker
# This calculates and caches the signature in the database # This calculates and caches the signature in the database
commits.each do |commit| commits.each do |commit|
commit&.signature commit&.signature
rescue => e rescue StandardError => e
Gitlab::AppLogger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}") Gitlab::AppLogger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}")
end end
end end
......
...@@ -12,7 +12,7 @@ class EmailReceiverWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -12,7 +12,7 @@ class EmailReceiverWorker # rubocop:disable Scalability/IdempotentWorker
begin begin
Gitlab::Email::Receiver.new(raw).execute Gitlab::Email::Receiver.new(raw).execute
rescue => e rescue StandardError => e
handle_failure(raw, e) handle_failure(raw, e)
end end
end end
......
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
def perform(project_id, jira_issue_id, issue_attributes, waiter_key) def perform(project_id, jira_issue_id, issue_attributes, waiter_key)
issue_id = create_issue(issue_attributes, project_id) issue_id = create_issue(issue_attributes, project_id)
JiraImport.cache_issue_mapping(issue_id, jira_issue_id, project_id) JiraImport.cache_issue_mapping(issue_id, jira_issue_id, project_id)
rescue => ex rescue StandardError => ex
# Todo: Record jira issue id(or better jira issue key), # Todo: Record jira issue id(or better jira issue key),
# so that we can report the list of failed to import issues to the user # so that we can report the list of failed to import issues to the user
# see https://gitlab.com/gitlab-org/gitlab/-/issues/211653 # see https://gitlab.com/gitlab-org/gitlab/-/issues/211653
......
...@@ -28,7 +28,7 @@ module ObjectPool ...@@ -28,7 +28,7 @@ module ObjectPool
pool.create_object_pool pool.create_object_pool
pool.mark_ready pool.mark_ready
rescue => e rescue StandardError => e
pool.mark_failed pool.mark_failed
raise e raise e
end end
......
...@@ -132,7 +132,7 @@ module ObjectStorage ...@@ -132,7 +132,7 @@ module ObjectStorage
def process_uploader(uploader) def process_uploader(uploader)
MigrationResult.new(uploader.upload).tap do |result| MigrationResult.new(uploader.upload).tap do |result|
uploader.migrate!(@to_store) uploader.migrate!(@to_store)
rescue => e rescue StandardError => e
result.error = e result.error = e
end end
end end
......
...@@ -22,7 +22,7 @@ module Packages ...@@ -22,7 +22,7 @@ module Packages
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
# ignore. likely due to object already being deleted. # ignore. likely due to object already being deleted.
end end
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.log_exception(e) Gitlab::ErrorTracking.log_exception(e)
end end
end end
......
...@@ -15,7 +15,7 @@ module Packages ...@@ -15,7 +15,7 @@ module Packages
return unless project return unless project
Gitlab::Composer::Cache.new(project: project, name: package_name, last_page_sha: last_page_sha).execute Gitlab::Composer::Cache.new(project: project, name: package_name, last_page_sha: last_page_sha).execute
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.log_exception(e, project_id: project_id) Gitlab::ErrorTracking.log_exception(e, project_id: project_id)
end end
end end
......
...@@ -10,7 +10,7 @@ class PagesDomainRemovalCronWorker # rubocop:disable Scalability/IdempotentWorke ...@@ -10,7 +10,7 @@ class PagesDomainRemovalCronWorker # rubocop:disable Scalability/IdempotentWorke
def perform def perform
PagesDomain.for_removal.with_logging_info.find_each do |domain| PagesDomain.for_removal.with_logging_info.find_each do |domain|
with_context(project: domain.project) { domain.destroy! } with_context(project: domain.project) { domain.destroy! }
rescue => e rescue StandardError => e
Gitlab::ErrorTracking.track_exception(e) Gitlab::ErrorTracking.track_exception(e)
end end
end end
......
...@@ -11,7 +11,7 @@ class ProjectServiceWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -11,7 +11,7 @@ class ProjectServiceWorker # rubocop:disable Scalability/IdempotentWorker
data = data.with_indifferent_access data = data.with_indifferent_access
service = Service.find(hook_id) service = Service.find(hook_id)
service.execute(data) service.execute(data)
rescue => error rescue StandardError => error
service_class = service&.class&.name || "Not Found" service_class = service&.class&.name || "Not Found"
logger.error class: self.class.name, service_class: service_class, message: error.message logger.error class: self.class.name, service_class: service_class, message: error.message
end end
......
...@@ -24,7 +24,7 @@ module Projects ...@@ -24,7 +24,7 @@ module Projects
return if Gitlab::Database.read_only? # GitGarbageCollectWorker may be run on a Geo secondary return if Gitlab::Database.read_only? # GitGarbageCollectWorker may be run on a Geo secondary
::Gitlab::Cleanup::OrphanLfsFileReferences.new(resource, dry_run: false, logger: logger).run! ::Gitlab::Cleanup::OrphanLfsFileReferences.new(resource, dry_run: false, logger: logger).run!
rescue => err rescue StandardError => err
Gitlab::GitLogger.warn(message: "Cleaning up orphan LFS objects files failed", error: err.message) Gitlab::GitLogger.warn(message: "Cleaning up orphan LFS objects files failed", error: err.message)
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(err) Gitlab::ErrorTracking.track_and_raise_for_dev_exception(err)
end end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment