Class: Derailleur::InternalErrorHandler

Inherits:
RackHandler show all
Defined in:
lib/derailleur/core/handler.rb

Overview

This handler returns the error as text/plain object If the error respond_to http_status, then it will modify the HTTP status code accordingly.

Instance Attribute Summary

Attributes included from Handler::Rack

#status

Attributes inherited from Handler

#ctx, #env, #object

Instance Method Summary collapse

Methods included from Handler::Rack

#initialize_rack, #to_rack_output

Constructor Details

#initialize(err, env, ctx) ⇒ InternalErrorHandler

Returns a new instance of InternalErrorHandler.



108
109
110
111
112
113
114
115
# File 'lib/derailleur/core/handler.rb', line 108

def initialize(err, env, ctx)
  super
  if err.respond_to? :http_status
    @status = err.http_status
  else
    @status = 500
  end
end

Instance Method Details

#headersObject



117
118
119
# File 'lib/derailleur/core/handler.rb', line 117

def headers
  {'Content-Type' => 'text/plain'}
end

#pageObject



121
122
123
124
125
# File 'lib/derailleur/core/handler.rb', line 121

def page
  [err.class.name,
  err.message,
  err.backtrace].join("\n")
end