ActiveSupport: Generalize error message dependant logic a bit.

Other Ruby implementations might not implement error messages the same
as MRI. For example, Rubinius has a bit different wording for
NameError messages in general and ArgumentError messages on Hash.
ActionPack: Generalize error message dependant logic a bit.

Other Ruby implementations might not implement error messages the same as MRI.
For example, Rubinius has a bit different wording for NoMethodError messages.