Skip to content

Commit

Permalink
Rescue ActiveRecord::ConnectionNotEstablished errors during
Browse files Browse the repository at this point in the history
`const_get`

Resolves #2004
  • Loading branch information
KaanOzkan committed Dec 6, 2024
1 parent cc54939 commit f6f4b18
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/tapioca/runtime/reflection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ def constant_defined?(constant)
end
def constantize(symbol, inherit: false, namespace: Object)
namespace.const_get(symbol, inherit)
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError
rescue NameError, LoadError, RuntimeError, ArgumentError, TypeError, ActiveRecord::ConnectionNotEstablished
UNDEFINED_CONSTANT
rescue => e
if defined?(ActiveRecord) && defined?(ActiveRecord::ConnectionNotEstablished) && e.is_a?(ActiveRecord::ConnectionNotEstablished)
UNDEFINED_CONSTANT
else
raise
end
end

sig { params(object: BasicObject).returns(T::Class[T.anything]).checked(:never) }
Expand Down

0 comments on commit f6f4b18

Please sign in to comment.