lib/nanoc/cli/error_handler.rb
# 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
Attempts to find a resolution for the given error, or nil if no
resolution can be automatically obtained.
Attempts to find a resolution for the given error or nil if no resolution can be automatically obtained .
def resolution_for(error)
      case error
      when LoadError
        matches = error.message.match(/(no such file to load|cannot load such file) -- ([^\s]+)/)
        return nil if matches.nil?
        gem_name = GEM_NAMES[matches[2]]
        if gem_name
          if self.using_bundler?
            "Make sure the gem is added to Gemfile and run `bundle install`."
          else
            "Install the '#{gem_name}' gem using `gem install #{gem_name}`."
          end
        end
      when RuntimeError
        if error.message =~ /^can't modify frozen/
          "You attempted to modify immutable data. Some data, such as " \
          "item/layout attributes and raw item/layout content, can not " \
          "be modified once compilation has started. (This was " \
          "unintentionally possible in 3.1.x and before, but has been " \
          "disabled in 3.2.x in order to allow compiler optimisations.)"
        end
      end
    end
def resolution_for ( error ) case error when LoadError matches = error . message . match ( / (no such file to load|cannot load such file) -- ([^ \s ]+) / ) return nil if matches . nil? gem_name = GEM_NAMES [ matches [ 2 ] ] if gem_name if self . using_bundler? "Make sure the gem is added to Gemfile and run `bundle install`." else "Install the '#{gem_name}' gem using `gem install #{gem_name}`." end end when RuntimeError if error . message =~ / ^can't modify frozen / "You attempted to modify immutable data. Some data, such as " "item/layout attributes and raw item/layout content, can not " "be modified once compilation has started. (This was " "unintentionally possible in 3.1.x and before, but has been " "disabled in 3.2.x in order to allow compiler optimisations.)" end end end
Attempts to find a resolution for the given error, or nil if no
resolution can be automatically obtained.
Attempts to find a resolution for the given error or nil if no resolution can be automatically obtained .
# Get gem name # Build message
The resolution for the given error
The resolution for the given error
String
error
error The error to find a resolution for
error The error to find a resolution for