Module: GknitDiagnostics
- Defined in:
- lib/gknit/diagnostics.rb
Constant Summary collapse
- INTERNAL_MESSAGE_PATTERNS =
[ /undefined method .*R::NewBridgeAdapter/i, /Result protocol:/i, /invalid connection/i, /galaaz_callback_call timeout/i, /NewBridge::SessionClient::/i, /Unsupported graphics device/i ].freeze
Class Method Summary collapse
- .internal_error?(error) ⇒ Boolean
- .internal_errors ⇒ Object
- .print_report(io = $stderr) ⇒ Object
- .record(chunk_label:, error:) ⇒ Object
- .reset! ⇒ Object
Class Method Details
.internal_error?(error) ⇒ Boolean
23 24 25 26 |
# File 'lib/gknit/diagnostics.rb', line 23 def self.internal_error?(error) msg = error..to_s INTERNAL_MESSAGE_PATTERNS.any? { |rx| rx.match?(msg) } end |
.internal_errors ⇒ Object
19 20 21 |
# File 'lib/gknit/diagnostics.rb', line 19 def self.internal_errors @internal_errors end |
.print_report(io = $stderr) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/gknit/diagnostics.rb', line 40 def self.print_report(io = $stderr) return if @internal_errors.nil? || @internal_errors.empty? io.puts io.puts 'gknit internal errors detected:' @internal_errors.each_with_index do |entry, idx| io.puts " #{idx + 1}) chunk=#{entry[:chunk]} | #{entry[:klass]}: #{entry[:message]}" end end |
.record(chunk_label:, error:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gknit/diagnostics.rb', line 28 def self.record(chunk_label:, error:) return unless internal_error?(error) @internal_errors << { chunk: chunk_label.to_s, klass: error.class.to_s, message: error..to_s } rescue StandardError nil end |
.reset! ⇒ Object
15 16 17 |
# File 'lib/gknit/diagnostics.rb', line 15 def self.reset! @internal_errors = [] end |