Skip to content

Commit 2d3e5e0

Browse files
author
Dominik Goltermann
committed
Fix Definition.CoercibleType raising ArgumentError
1 parent 7f9fe0c commit 2d3e5e0

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

lib/definition/dsl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def CoercibleType(klass) # rubocop:disable Naming/MethodName
4242
end
4343
Types::Type.new(:type, klass) do |value|
4444
method(klass.name).call(value)
45-
rescue ArgumentError
45+
rescue ArgumentError, TypeError
4646
value
4747
end
4848
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"": "<Definition::ConformError \n\t message: \"Is of type StandardError instead of Float\", \n\t json_pointer: \"/\">"
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Is of type StandardError instead of Float
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[0] <Definition::ConformError
2+
message: "Is of type StandardError instead of Float",
3+
json_pointer: "/">

spec/integration/coercible_type_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121

2222
it_behaves_like "it does not conform"
2323
end
24+
25+
context "with incoercible error class instance" do
26+
let(:value) { StandardError.new("oops") }
27+
28+
it_behaves_like "it does not conform"
29+
end
2430
end

0 commit comments

Comments
 (0)