diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb
index a9e429a29f4ae7a580e66d16cf1634c03637835e..9360afedfcb4b1df697f97482d8aede813a4dac5 100644
--- a/lib/gitlab/highlight.rb
+++ b/lib/gitlab/highlight.rb
@@ -35,8 +35,8 @@ module Gitlab
 
     def lexer
       @lexer ||= custom_language || begin
-        Rouge::Lexer.guess(filename: blob_name, source: blob_content).new
-      rescue Rouge::Lexer::AmbiguousGuess => e
+        Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new
+      rescue Rouge::Guesser::Ambiguous => e
         e.alternatives.sort_by(&:tag).first
       end
     end