Class: PointRb::Actions::ErrorHandlerCommandline

Inherits:
Object
  • Object
show all
Defined in:
lib/pointrb/actions/error_handler_commandline.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorHandlerCommandline

Returns a new instance of ErrorHandlerCommandline.



4
5
6
# File 'lib/pointrb/actions/error_handler_commandline.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pointrb/actions/error_handler_commandline.rb', line 8

def call(env)
  begin
    @app.call(env)
  rescue Exceptions::SyntaxErrorInLayout => e
    error_msg e.message, 1
  rescue Exceptions::ProjectPathExists => e
    error_msg e.message, 2
  rescue Exceptions::PointRbWasAlreadInitialized => e
    error_msg e.message, 3
  rescue Exceptions::LayoutNotFound => e
    error_msg e.message, 4
  rescue Exception => e

    if env.command_line_options[:verbose]
      message = e.message
    else
      message = 'An unknown error occured. If you would like to see a more verbose output, then please use the --verbose option.'
    end

    error_msg message, -1
  end
end