The problem is handled with exceptions plus Java's try-with-resources or C#'s using statements or Python's context managers though, right?
Furthermore in Java since version 7 you can actually see both exceptions with the suppressed exceptions pattern.