module PointRb module Actions class ErrorHandlerCommandline def initialize(app) @app = app end 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 private def error_msg(msg, return_code) $stderr.puts "[Error] #{msg} Exit!" exit return_code end end end end