Skip to content

Commit 4e8abf0

Browse files
committed
Initialize error data using constructors directly
1 parent e0f412c commit 4e8abf0

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

lib/grape/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def run
255255
run_filters befores, :before
256256

257257
if (allowed_methods = env[Grape::Env::GRAPE_ALLOWED_METHODS])
258-
raise Grape::Exceptions::MethodNotAllowed, header.merge('Allow' => allowed_methods) unless options?
258+
raise Grape::Exceptions::MethodNotAllowed.new(header.merge('Allow' => allowed_methods)) unless options?
259259
header 'Allow', allowed_methods
260260
response_object = ''
261261
status 204

lib/grape/parser/json.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def call(object, _env)
88
::Grape::Json.load(object)
99
rescue ::Grape::Json::ParseError
1010
# handle JSON parsing errors via the rescue handlers or provide error message
11-
raise Grape::Exceptions::InvalidMessageBody, 'application/json'
11+
raise Grape::Exceptions::InvalidMessageBody.new('application/json')
1212
end
1313
end
1414
end

lib/grape/parser/xml.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def call(object, _env)
88
::Grape::Xml.parse(object)
99
rescue ::Grape::Xml::ParseError
1010
# handle XML parsing errors via the rescue handlers or provide error message
11-
raise Grape::Exceptions::InvalidMessageBody, 'application/xml'
11+
raise Grape::Exceptions::InvalidMessageBody.new('application/xml')
1212
end
1313
end
1414
end

lib/grape/request.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(env, **options)
1616
def params
1717
@params ||= build_params
1818
rescue EOFError
19-
raise Grape::Exceptions::EmptyMessageBody, content_type
19+
raise Grape::Exceptions::EmptyMessageBody.new(content_type)
2020
end
2121

2222
def headers

lib/grape/validations/validators/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def validate!(params)
5555
end
5656
end
5757

58-
raise Grape::Exceptions::ValidationArrayErrors, array_errors if array_errors.any?
58+
raise Grape::Exceptions::ValidationArrayErrors.new(array_errors) if array_errors.any?
5959
end
6060

6161
def self.convert_to_short_name(klass)

lib/grape/validations/validators/multiple_params_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def validate!(params)
1616
end
1717
end
1818

19-
raise Grape::Exceptions::ValidationArrayErrors, array_errors if array_errors.any?
19+
raise Grape::Exceptions::ValidationArrayErrors.new(array_errors) if array_errors.any?
2020
end
2121

2222
private

0 commit comments

Comments
 (0)