mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
66eb3f02cc
Currently Rack raises a TypeError when it encounters a malformed or ambiguous hash like `foo[]=bar&foo[4]=bar`. Rather than pass this through to the application this commit captures the exception and re-raises it using a new ActionController::BadRequest exception. The new ActionController::BadRequest exception returns a 400 error instead of the 500 error that would've been returned by the original TypeError. This allows exception notification libraries to ignore these errors if so desired. Closes #3051
47 lines
1.2 KiB
Ruby
47 lines
1.2 KiB
Ruby
module ActionController
|
|
class ActionControllerError < StandardError #:nodoc:
|
|
end
|
|
|
|
class BadRequest < ActionControllerError #:nodoc:
|
|
end
|
|
|
|
class RenderError < ActionControllerError #:nodoc:
|
|
end
|
|
|
|
class RoutingError < ActionControllerError #:nodoc:
|
|
attr_reader :failures
|
|
def initialize(message, failures=[])
|
|
super(message)
|
|
@failures = failures
|
|
end
|
|
end
|
|
|
|
class MethodNotAllowed < ActionControllerError #:nodoc:
|
|
def initialize(*allowed_methods)
|
|
super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
|
|
end
|
|
end
|
|
|
|
class NotImplemented < MethodNotAllowed #:nodoc:
|
|
end
|
|
|
|
class UnknownController < ActionControllerError #:nodoc:
|
|
end
|
|
|
|
class MissingFile < ActionControllerError #:nodoc:
|
|
end
|
|
|
|
class SessionOverflowError < ActionControllerError #:nodoc:
|
|
DEFAULT_MESSAGE = 'Your session data is larger than the data column in which it is to be stored. You must increase the size of your data column if you intend to store large data.'
|
|
|
|
def initialize(message = nil)
|
|
super(message || DEFAULT_MESSAGE)
|
|
end
|
|
end
|
|
|
|
class UnknownHttpMethod < ActionControllerError #:nodoc:
|
|
end
|
|
|
|
class UnknownFormat < ActionControllerError #:nodoc:
|
|
end
|
|
end
|