diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-01-19 16:56:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 13:56:56 +1300 |
commit | 723b5384f2dcd6541477a42262f75e45276b595c (patch) | |
tree | 80835a37418b865c89a08ee89f0ec413fc1c37a5 /lib/rack/query_parser.rb | |
parent | 54368a0981c46c2c62137e47795b38de50dabefb (diff) | |
download | rack-723b5384f2dcd6541477a42262f75e45276b595c.tar.gz |
Add general `Rack::BadRequest`. (#2019)
Used to communicate a class of exceptions that represent 400 Bad Request
semantics.
Diffstat (limited to 'lib/rack/query_parser.rb')
-rw-r--r-- | lib/rack/query_parser.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rack/query_parser.rb b/lib/rack/query_parser.rb index a89c4c7f..7c9621ed 100644 --- a/lib/rack/query_parser.rb +++ b/lib/rack/query_parser.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require_relative 'bad_request' + module Rack class QueryParser DEFAULT_SEP = /[&] */n @@ -7,16 +9,22 @@ module Rack # ParameterTypeError is the error that is raised when incoming structural # parameters (parsed by parse_nested_query) contain conflicting types. - class ParameterTypeError < TypeError; end + class ParameterTypeError < TypeError + include BadRequest + end # InvalidParameterError is the error that is raised when incoming structural # parameters (parsed by parse_nested_query) contain invalid format or byte # sequence. - class InvalidParameterError < ArgumentError; end + class InvalidParameterError < ArgumentError + include BadRequest + end # ParamsTooDeepError is the error that is raised when params are recursively # nested over the specified limit. - class ParamsTooDeepError < RangeError; end + class ParamsTooDeepError < RangeError + include BadRequest + end def self.make_default(param_depth_limit) new Params, param_depth_limit |