Avoid use of deprecated methods on error objects