Skip to content

Add @exception variable for programmatic error inspection#1

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/improve-debugging-capabilities
Draft

Add @exception variable for programmatic error inspection#1
Copilot wants to merge 4 commits intomasterfrom
copilot/improve-debugging-capabilities

Conversation

Copy link

Copilot AI commented Dec 3, 2025

Proposed Changes

  • Add @exception instance variable that captures all exceptions regardless of @debug flag, enabling programmatic error inspection without stderr parsing
  • Fix initialization bugs: use DEFAULT_TIMEOUT instead of undefined timeout variable, use @request_type instead of undefined request_type variable
  • Replace $! global variable with explicit exception parameters in all 19 rescue blocks per Ruby best practices

Usage:

ms = MineStat.new("unreachable.example.com", 25565, timeout: 2, debug: false)
if ms.exception
  # Access exception details programmatically without enabling debug mode
  puts "Error: #{ms.exception.class} - #{ms.exception.message}"
end

Previously, errors were only visible via $stderr.puts when debug: true. Now exceptions are always accessible via the exception attribute, improving debuggability without requiring verbose stderr output.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 10.255.255.1
    • Triggering command: `/usr/bin/ruby ruby -e
      require_relative 'lib/minestat'

Test different exception scenarios

puts 'Test 1: Connection refused (Errno::ECONNREFUSED)'
ms1 = MineStat.new('localhost', 1, timeout: 2, debug: false)
puts ' Exception class: ' + ms1.exception.class.to_s if ms1.except` (dns block)

  • another-nonexistent-server-12345.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/demo_exception.rb (dns block)
  • another-server.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/final_verification.rb (dns block)
  • another-unreachable-12345.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/test_exception.rb (dns block)
  • another-unreachable.example.com
    • Triggering command: /usr/bin/ruby ruby example_exception.rb (dns block)
  • frag.land
    • Triggering command: /usr/bin/ruby ruby /tmp/test_exception.rb (dns block)
  • nonexistent-minecraft-server-12345.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/demo_exception.rb (dns block)
  • nonexistent-server.example.com
    • Triggering command: /usr/bin/ruby ruby example_exception.rb (dns block)
    • Triggering command: /usr/bin/ruby ruby /tmp/final_verification.rb (dns block)
  • test
    • Triggering command: /usr/bin/ruby ruby -e require_relative 'lib/minestat'; ms = MineStat.new('test', 25565); puts 'Success' (dns block)
    • Triggering command: /usr/bin/ruby ruby -e require_relative 'lib/minestat'; ms = MineStat.new('test', 25565, {}); puts 'Timeout is: ' + ms.timeout.to_s (dns block)
  • test-server.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/final_verification.rb (dns block)
  • test.example.com
    • Triggering command: `/usr/bin/ruby ruby -e
      require_relative 'lib/minestat'

Pass empty options hash to trigger the bug

ms = MineStat.new('test.example.com', 25565, {})
puts 'Finished'` (dns block)

  • Triggering command: /usr/bin/ruby ruby -e require_relative 'lib/minestat' puts 'Creating MineStat object...' ms = MineStat.new('test.example.com', 25565, {}) puts 'Created successfully' puts 'Timeout: ' + ms.timeout.inspect puts 'Request type: ' + ms.request_type.inspect puts 'Exception: ' + ms. (dns block)
  • Triggering command: /usr/bin/ruby ruby -e require_relative 'lib/minestat' puts 'Test 1: With no timeout option' ms1 = MineStat.new('test.example.com', 25565, {}) puts ' Timeout: ' + ms1.timeout.inspect + ' (should be DEFAULT_TIMEOUT=' + MineStat::DEFAULT_TIMEOUT.to_s + ')' puts ' Request type: (dns block)
  • unreachable-server-12345.example.com
    • Triggering command: /usr/bin/ruby ruby /tmp/test_exception.rb (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

현재 코드는 오류를 rescue => exception 등으로 먹고 $stderr.puts로 표시하도록만 구현되어 있어. 이를 내부에 @exception 변수를 만들고 이곳에 오류 객체를 집어넣도록 해서 디버그의 용의성을 높이고자 해. 이 변수는 if @debug에 상관 없이 오류 객체를 집어넣도록 구현해줘.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 3 commits December 3, 2025 03:22
Co-authored-by: ryush00 <4997174+ryush00@users.noreply.github.com>
Co-authored-by: ryush00 <4997174+ryush00@users.noreply.github.com>
Co-authored-by: ryush00 <4997174+ryush00@users.noreply.github.com>
Copilot AI changed the title [WIP] Update error handling to store exception in variable Add @exception variable for programmatic error inspection Dec 3, 2025
Copilot AI requested a review from ryush00 December 3, 2025 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants