Skip to content

Group incomplete and empty message into MessageError #515

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
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
23 changes: 12 additions & 11 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def create_client(outgoing_queue)
end

class InitializationError < StandardError; end
class IncompleteMessageError < StandardError; end
class EmptyMessageError < StandardError; end
class MessageError < StandardError; end
class IncompleteMessageError < MessageError; end
class EmptyMessageError < MessageError; end

extend T::Sig

Expand Down Expand Up @@ -115,7 +116,7 @@ def initialize(outgoing_queue)
sig { params(server_addon_path: String).void }
def register_server_addon(server_addon_path)
send_notification("server_addon/register", server_addon_path: server_addon_path)
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to register server addon #{server_addon_path}",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -126,7 +127,7 @@ def register_server_addon(server_addon_path)
sig { params(name: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def model(name)
make_request("model", name: name)
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to get model information",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -146,7 +147,7 @@ def association_target_location(model_name:, association_name:)
model_name: model_name,
association_name: association_name,
)
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to get association location",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -157,7 +158,7 @@ def association_target_location(model_name:, association_name:)
sig { params(name: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def route_location(name)
make_request("route_location", name: name)
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to get route location",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -168,7 +169,7 @@ def route_location(name)
sig { params(controller: String, action: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def route(controller:, action:)
make_request("route_info", controller: controller, action: action)
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to get route information",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -191,7 +192,7 @@ def delegate_notification(server_addon_name:, request_name:, **params)
def pending_migrations_message
response = make_request("pending_migrations_message")
response[:pending_migrations_message] if response
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed when checking for pending migrations",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -202,7 +203,7 @@ def pending_migrations_message
sig { returns(T.nilable(T::Hash[Symbol, T.untyped])) }
def run_migrations
make_request("run_migrations")
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to run migrations",
type: RubyLsp::Constant::MessageType::ERROR,
Expand All @@ -225,15 +226,15 @@ def delegate_request(server_addon_name:, request_name:, **params)
request_name: request_name,
**params,
)
rescue IncompleteMessageError
rescue MessageError
nil
end

sig { void }
def trigger_reload
log_message("Reloading Rails application")
send_notification("reload")
rescue IncompleteMessageError
rescue MessageError
log_message(
"Ruby LSP Rails failed to trigger reload",
type: RubyLsp::Constant::MessageType::ERROR,
Expand Down
Loading