File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
lib/ruby_lsp/ruby_lsp_rails Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change 8
8
9
9
module RubyLsp
10
10
module Rails
11
+ class InvalidAddonError < RuntimeError
12
+ end
13
+
11
14
class Server
12
15
class << self
13
16
def require_server_addon ( gem_name )
14
- const = nil
15
- File . open ( "ruby-lsp-rails.txt" , "a" ) do |f |
16
- f . puts ( "#{ Time . now } trying to get addon..." )
17
- require "ruby_lsp/#{ gem_name } /addon"
18
- f . puts ( "#{ Time . now } past require" )
19
- const = Object . const_get ( "RubyLsp::#{ gem_name . classify } ::Addon" ) # rubocop:disable Sorbet/ConstantsFromStrings
20
- f . puts ( "#{ Time . now } past constant ref" )
21
- rescue => e
22
- # TODO: rescue constnat not exising
23
- # TODO: - show error to user if invalid name given / send back to client
24
- f . puts ( e . full_message )
25
- end
26
- const
17
+ require "ruby_lsp/#{ gem_name } /addon"
18
+ Object . const_get ( "RubyLsp::#{ gem_name . classify } ::Addon" ) # rubocop:disable Sorbet/ConstantsFromStrings
19
+ rescue LoadError , NameError
20
+ raise InvalidAddonError , "Failed to load addon '#{ gem_name } '"
27
21
end
28
22
end
29
23
You can’t perform that action at this time.
0 commit comments