Code

Added upstream patch bts496847-error-handling.