Class: BruteCLI::BufferOutput::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/brute_cli/buffer_output/error.rb

Overview

Renderable error badge with pretty-printed message.

puts BufferOutput::Error.new(err)
# => "✖ ERROR"
# => "\"Something went wrong\""

Instance Method Summary collapse

Constructor Details

#initialize(err) ⇒ Error

Returns a new instance of Error.



16
17
18
# File 'lib/brute_cli/buffer_output/error.rb', line 16

def initialize(err)
  @err = err
end

Instance Method Details

#to_sObject



20
21
22
23
24
# File 'lib/brute_cli/buffer_output/error.rb', line 20

def to_s
  header = "#{Emoji::CROSS} #{"ERROR".colorize(ERROR_BG)}"
  parsed = JSON.parse(@err.message) rescue @err.message
  "#{header}\n#{parsed.pretty_inspect.chomp}"
end