Exception: Webgen::RenderError

Inherits:
Error
  • Object
show all
Defined in:
lib/webgen/error.rb

Overview

This error is raised when an error condition occurs during rendering of a node.

Instance Attribute Summary collapse

Attributes inherited from Error

#location, #path

Instance Method Summary collapse

Methods inherited from Error

error_file, error_line

Constructor Details

#initialize(msg_or_error, location = nil, path = nil, error_path = nil, line = nil) ⇒ RenderError

Create a new RenderError.



78
79
80
81
82
# File 'lib/webgen/error.rb', line 78

def initialize(msg_or_error, location = nil, path = nil, error_path = nil, line = nil)
  super(msg_or_error, location, path)
  @error_path = error_path || (Exception === msg_or_error ? self.class.error_file(msg_or_error) : nil)
  @line = line || (Exception === msg_or_error ? self.class.error_line(msg_or_error) : nil)
end

Instance Attribute Details

#error_pathObject

The path of the file where the error happened. This can be different from #path (e.g. a page file is rendered but the error happens in a used template).



72
73
74
# File 'lib/webgen/error.rb', line 72

def error_path
  @error_path
end

#lineObject

The line number in the error_path where the errror happened.



75
76
77
# File 'lib/webgen/error.rb', line 75

def line
  @line
end

Instance Method Details

#messageObject

:nodoc:



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/webgen/error.rb', line 84

def message # :nodoc:
  msg = 'Error'
  msg << " at #{@location}" if @location
  if @error_path
    msg += " in <#{@error_path}"
    msg += ":~#{@line}" if @line
    msg += ">"
  end
  msg << ' while rendering'
  msg << (!@path.to_s.empty? ? " <#{@path}>" : ' the website')
  msg << ":\n    " << super(true)
end