Commit 89824642 authored by Kamil Trzciński's avatar Kamil Trzciński

Add `QueryAnalyzerError` based on `Exception` to raise in tests

We use `Exception` since in tests we have very often very wide resuces.
Wide exception ensures that we correctly will raise it in tests.
parent 185222aa
......@@ -61,7 +61,7 @@ module Gitlab
next if analyzer.suppressed?
analyzer.analyze(parsed)
rescue StandardError => e
rescue StandardError, QueryAnalyzers::Base::QueryAnalyzerError => e
# We catch all standard errors to prevent validation errors to introduce fatal errors in production
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end
......@@ -75,7 +75,7 @@ module Gitlab
true
end
rescue StandardError => e
rescue StandardError, QueryAnalyzers::Base::QueryAnalyzerError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
false
......@@ -88,7 +88,7 @@ module Gitlab
def end!
enabled_analyzers.select do |analyzer|
analyzer.end!
rescue StandardError => e
rescue StandardError, QueryAnalyzers::Base::QueryAnalyzerError => e
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
end
......
......@@ -4,6 +4,9 @@ module Gitlab
module Database
module QueryAnalyzers
class Base
# `Exception` to ensure that is not easily rescued when running in test env
QueryAnalyzerError = Class.new(Exception) # rubocop:disable Lint/InheritException
def self.suppressed?
Thread.current[self.suppress_key]
end
......
......@@ -4,7 +4,7 @@ module Gitlab
module Database
module QueryAnalyzers
class PreventCrossDatabaseModification < Database::QueryAnalyzers::Base
CrossDatabaseModificationAcrossUnsupportedTablesError = Class.new(StandardError)
CrossDatabaseModificationAcrossUnsupportedTablesError = Class.new(QueryAnalyzerError)
# This method will allow cross database modifications within the block
# Example:
......
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