mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #16338 from robin850/rbx-safe-constantize
Avoid relying on error messages when rescuing
This commit is contained in:
commit
898bdc5c54
1 changed files with 2 additions and 2 deletions
|
@ -303,8 +303,8 @@ module ActiveSupport
|
|||
def safe_constantize(camel_cased_word)
|
||||
constantize(camel_cased_word)
|
||||
rescue NameError => e
|
||||
raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ ||
|
||||
e.name.to_s == camel_cased_word.to_s
|
||||
raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) ||
|
||||
e.name.to_s == camel_cased_word.to_s)
|
||||
rescue ArgumentError => e
|
||||
raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue