lib/angelo/responder.rb in angelo-0.1.9 vs lib/angelo/responder.rb in angelo-0.1.10
- old
+ new
@@ -47,25 +47,27 @@
def request= request
@params = nil
@redirect = nil
@request = request
handle_request
- respond
end
def handle_request
if @response_handler
@base.before if @base.respond_to? :before
@body = @response_handler.bind(@base).call || ''
@base.after if @base.respond_to? :after
+ respond
else
raise NotImplementedError
end
rescue JSON::ParserError => jpe
handle_error jpe, :bad_request, false
rescue FormEncodingError => fee
handle_error fee, :bad_request, false
+ rescue RequestError => re
+ handle_error re, re.type, false
rescue => e
handle_error e
end
def handle_error _error, type = :internal_server_error, report = true
@@ -82,10 +84,15 @@
def error_message _error
case
when respond_with?(:json)
{ error: _error.message }.to_json
else
- _error.message
+ case _error.message
+ when Hash
+ _error.message.to_s
+ else
+ _error.message
+ end
end
end
def headers hs = nil
@headers ||= self.class.default_headers.dup