Sha256: 65bde7bc74643be51814e67cb4655c7cdc3a6763f3b7edaea497555a24c007bf

Contents?: true

Size: 1004 Bytes

Versions: 3

Compression:

Stored size: 1004 Bytes

Contents

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pointrb-0.1.2 lib/pointrb/actions/error_handler_commandline.rb
pointrb-0.1.1 lib/pointrb/actions/error_handler_commandline.rb
pointrb-0.1.0 lib/pointrb/actions/error_handler_commandline.rb