Commit e1acca6e authored by Shubham Kumar's avatar Shubham Kumar Committed by Rémy Coutable

Resolves rubocop offense Style/RescueStandardError

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