summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-27 11:45:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-27 11:45:16 +0000
commitf444f745544528accf5811bb9a8fb0a252775d3b (patch)
treec248e283ea2825b68f405e738faea0e56ed57bba /lib
parent58fa510acd34ab3c8b36be95f5e7b58dd9b0f5f4 (diff)
downloadgitlab-ce-f444f745544528accf5811bb9a8fb0a252775d3b.tar.gz
Add latest changes from gitlab-org/gitlab@12-6-stable-ee
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb b/lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb
index a403275fd4e..1e490e52c43 100644
--- a/lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb
+++ b/lib/gitlab/error_tracking/stack_trace_highlight_decorator.rb
@@ -28,7 +28,7 @@ module Gitlab
end
def highlight_entry_context(filename, context)
- language = Rouge::Lexer.guess_by_filename(filename).tag
+ language = guess_language_by_filename(filename)
context.map do |line_number, line_of_code|
[
@@ -38,6 +38,12 @@ module Gitlab
]
end
end
+
+ def guess_language_by_filename(filename)
+ Rouge::Lexer.guess_by_filename(filename).tag
+ rescue Rouge::Guesser::Ambiguous => e
+ e.alternatives.min_by(&:tag)&.tag
+ end
end
end
end