Sha256: a669f9a6f2c178af362c5b8b651456597659a43bd89da0ba506a2f196fd299d5
Contents?: true
Size: 1.42 KB
Versions: 8
Compression:
Stored size: 1.42 KB
Contents
require 'webmachine/translation' require 'webmachine/version' module Webmachine extend Translation # Renders a standard error message body for the response. The # standard messages are defined in localization files. # @param [Fixnum] code the response status code # @param [Request] req the request object # @param [Response] req the response object # @param [Hash] options keys to override the defaults when rendering # the response body def self.render_error(code, req, res, options={}) res.code = code unless res.body title, message = t(["errors.#{code}.title", "errors.#{code}.message"], { :method => req.method, :error => res.error}.merge(options)) res.body = t("errors.standard_body", {:title => title, :message => message, :version => Webmachine::SERVER_STRING}.merge(options)) res.headers['Content-Type'] = "text/html" end end # Superclass of all errors generated by Webmachine. class Error < ::StandardError; end # Raised when the resource violates specific constraints on its API. class InvalidResource < Error; end # Raised when the client has submitted an invalid request, e.g. in # the case where a request header is improperly formed. Raising this # exception will result in a 400 response. class MalformedRequest < Error; end end # module Webmachine
Version data entries
8 entries across 7 versions & 1 rubygems