Skip to content

Commit c893b8f

Browse files
committed
Handle case where object doesn't support inspect
1 parent 2d104c7 commit c893b8f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/mongoid/errors/invalid_field_type_definition.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class InvalidFieldTypeDefinition < MongoidError
1515
# @param [ Object ] field_type The object which is expected to a be Symbol or String.
1616
# @param [ Object ] klass The object which is expected to be a Class or Module.
1717
def initialize(field_type, klass)
18+
type_inspection = field_type.try(:inspect) || field_type.class.inspect
19+
klass_inspection = klass.try(:inspect) || klass.class.inspect
1820
super(
1921
compose_message('invalid_field_type_definition',
20-
type_inspection: field_type.inspect, klass_inspection: klass.inspect)
22+
type_inspection: type_inspection, klass_inspection: klass_inspection)
2123
)
2224
end
2325
end

0 commit comments

Comments
 (0)