Skip to content

Commit 7a63050

Browse files
authored
Merge pull request #628 from Shopify/ko/rescue-more-exceptions
Rescue more exceptions in error handlers
2 parents cb9556d + 7aca10f commit 7a63050

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/ruby_lsp/ruby_lsp_rails/server.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def with_request_error_handling(request_name, &block)
6868
send_error_response("Request #{request_name} failed because database connection was not established.")
6969
rescue ActiveRecord::NoDatabaseError
7070
send_error_response("Request #{request_name} failed because the database does not exist.")
71-
rescue => e
72-
send_error_response("Request #{request_name} failed:\n#{e.full_message(highlight: false)}")
71+
rescue NotImplementedError, LoadError, SyntaxError, SystemExit, SystemStackError => e
72+
send_error_response("Request #{request_name} failed with #{e.class}:\n#{e.full_message(highlight: false)}")
73+
rescue StandardError => e
74+
send_error_response("Request #{request_name} failed with StandardError:\n#{e.full_message(highlight: false)}")
7375
end
7476

7577
# Handle possible errors for a notification. This should only be used for notifications, which means messages that
@@ -82,8 +84,10 @@ def with_notification_error_handling(notification_name, &block)
8284
log_message("Request #{notification_name} failed because database connection was not established.")
8385
rescue ActiveRecord::NoDatabaseError
8486
log_message("Request #{notification_name} failed because the database does not exist.")
85-
rescue => e
86-
log_message("Request #{notification_name} failed:\n#{e.full_message(highlight: false)}")
87+
rescue NotImplementedError, LoadError, SyntaxError, SystemExit, SystemStackError => e
88+
log_message("Request #{notification_name} failed with #{e.class}:\n#{e.full_message(highlight: false)}")
89+
rescue StandardError => e
90+
log_message("Request #{notification_name} failed with StandardError:\n#{e.full_message(highlight: false)}")
8791
end
8892

8993
#: (String, String, ?percentage: Integer?, ?message: String?) -> void

0 commit comments

Comments
 (0)