Make sure all error properties are preserved when converting into an Error object.