Skip to content

Rescue more exceptions in error handlers #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/ruby_lsp/ruby_lsp_rails/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def with_request_error_handling(request_name, &block)
send_error_response("Request #{request_name} failed because database connection was not established.")
rescue ActiveRecord::NoDatabaseError
send_error_response("Request #{request_name} failed because the database does not exist.")
rescue => e
send_error_response("Request #{request_name} failed:\n#{e.full_message(highlight: false)}")
rescue NotImplementedError, LoadError, SyntaxError, SystemExit, SystemStackError => e
send_error_response("Request #{request_name} failed with #{e.class}:\n#{e.full_message(highlight: false)}")
rescue StandardError => e
send_error_response("Request #{request_name} failed with StandardError:\n#{e.full_message(highlight: false)}")
end

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

#: (String, String, ?percentage: Integer?, ?message: String?) -> void
Expand Down
Loading