Class Nanoc::CLI::ErrorHandler
In: lib/nanoc/cli/error_handler.rb
Parent: Object

Catches errors and prints nice diagnostic messages, then exits.

@api private

Methods

Constants

GEM_NAMES = { 'adsf' => 'adsf', 'bluecloth' => 'bluecloth', 'builder' => 'builder', 'coderay' => 'coderay', 'cri' => 'cri', 'erubis' => 'erubis', 'escape' => 'escape', 'fog' => 'fog', 'haml' => 'haml', 'handlebars' => 'hbs', 'json' => 'json', 'kramdown' => 'kramdown', 'less' => 'less', 'listen' => 'listen', 'markaby' => 'markaby', 'maruku' => 'maruku', 'mime/types' => 'mime-types', 'nokogiri' => 'nokogiri', 'pry' => 'pry', 'rack' => 'rack', 'rack/cache' => 'rack-cache', 'rainpress' => 'rainpress', 'rdiscount' => 'rdiscount', 'redcarpet' => 'redcarpet', 'redcloth' => 'RedCloth', 'rubypants' => 'rubypants', 'sass' => 'sass', 'systemu' => 'systemu', 'w3c_validators' => 'w3c_validators'   A hash that contains the name of the gem for a given required file. If a `require` fails, the gem name is looked up in this hash.

Public Class methods

Disables error handling. This is used by the test cases to prevent error from being handled by the CLI while tests are running.

@api private

Re-enables error handling after it was disabled. This is used by the test cases to prevent error from being handled by the CLI while tests are running.

@api private

Enables error handling in the given block.

@option params [Nanoc::CLI::Command, nil] command The command that is

  currently being executed, or nil if there is none

@return [void]

@option params [Nanoc::CLI::Command, nil] command The command that is

  currently being executed, or nil if there is none

Prints the given error to stderr. Includes message, possible resolution (see {resolution_for}), compilation stack, backtrace, etc.

@param [Error] error The error that should be described

@return [void]

Public Instance methods

Enables error handling in the given block. This method should not be called directly; use {Nanoc::CLI::ErrorHandler.handle_while} instead.

@return [void]

@api private

Prints the given error to stderr. Includes message, possible resolution (see {resolution_for}), compilation stack, backtrace, etc.

@param [Error] error The error that should be described

@return [void]

Writes a compact representation of the error, suitable for a terminal, on the given stream (probably stderr).

@param [Error] error The error that should be described

@param [IO] stream The stream to write the description too

@api private

@return [void]

Writes a verbose representation of the error on the given stream.

@param [Error] error The error that should be described

@param [IO] stream The stream to write the description too

@api private

@return [void]

Protected Instance methods

@return [Nanoc::Compiler] The compiler for the current site

@return [Boolean] true if debug output is enabled, false if not

@see Nanoc::CLI.debug?

@return [Hash<String, Array>] A hash containing the gem names as keys and gem versions as value

Attempts to find a resolution for the given error, or nil if no resolution can be automatically obtained.

@param [Error] error The error to find a resolution for

@return [String] The resolution for the given error

@return [Nanoc::Site] The site that is currently being processed

@return [Array] The current compilation stack

[Validate]