Class: Redbreast::ErrorHandler

Inherits:
Object
  • Object
show all
Extended by:
Helper::Terminal
Defined in:
lib/redbreast/error_handler.rb

Overview

Class for handling errors that occurr

Class Method Summary collapse

Methods included from Helper::Terminal

prompt, success

Class Method Details

.handle(error) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/redbreast/error_handler.rb', line 13

def handle(error)
  prompt.error(
    case error
    when Errno::ENOENT
      "We could not find a file that we need:\n\n#{error.message}"
    else
      "An error happened. This might help:\n\n#{error.message}"
    end
  )
end

.rescuableObject



7
8
9
10
11
# File 'lib/redbreast/error_handler.rb', line 7

def rescuable
  yield
rescue StandardError => e
  handle(e)
end