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.



71
72
73
74
75
# File 'lib/wee/response.rb', line 71

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

Instance Method Details

#render(c) ⇒ Object



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

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