Skip to content

Commit

Permalink
Suppress Interrupt exception for LSP
Browse files Browse the repository at this point in the history
This PR suppresses the following backtrace of `Interrupt` exception for LSP:

## Before

```console
$ bundle exec rubocop --lsp
^C/Users/koic/.rbenv/versions/3.4-dev/lib/ruby/gems/3.4.0+0/gems/language_server-protocol-3.17.0.3/
lib/language_server/protocol/transport/io/reader.rb:16:in 'IO#gets': Interrupt
from /Users/koic/.rbenv/versions/3.4-dev/lib/ruby/gems/3.4.0+0/gems/language_server-protocol-3.17.0.3/
lib/language_server/protocol/transport/io/reader.rb:16:in 'LanguageServer::Protocol::Transport::Io::Reader#read'
        from /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/lsp/server.rb:35:in 'RuboCop::LSP::Server#start'
(snip)
```

## After

```console
$ bundle exec rubocop --lsp
^C
Exiting...
```
  • Loading branch information
koic committed May 6, 2024
1 parent 49c6e92 commit 1ec4ef9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rubocop/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ def run(args = ARGV)
rescue RuboCop::Error => e
warn Rainbow("Error: #{e.message}").red
STATUS_ERROR
rescue Interrupt
warn ''
warn 'Exiting...'
STATUS_INTERRUPTED
rescue Finished
STATUS_SUCCESS
rescue OptionParser::InvalidOption => e
Expand Down

0 comments on commit 1ec4ef9

Please sign in to comment.