Class: Wee::ErrorResponse

Inherits:
Response show all
Defined in:
lib/wee/response.rb

Constant Summary

Constants inherited from Response

Response::DEFAULT_HEADER

Instance Attribute Summary

Attributes inherited from Response

#content, #header, #status

Instance Method Summary collapse

Methods inherited from Response

#<<, #content_type, #content_type=, #cookies, #cookies?

Constructor Details

#initialize(exception) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



73
74
75
76
77
# File 'lib/wee/response.rb', line 73

def initialize(exception)
  super('text/html', '')
  @exception = exception
  render(@content)
end

Instance Method Details

#render(c) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/wee/response.rb', line 79

def render(c)
  c << "<html><head><title>Error occured</title></head><body>"
  c << "<p>#{ CGI.escapeHTML(@exception.inspect) }<br/>"
  c << @exception.backtrace.map{|s| CGI.escapeHTML(s)}.join("<br/>") 
  c << "</p>"
  c << "</body></html>"
end