4 ms·
Why is there a defer in the "try" example? To just show wrapping even though the "existing" one doesn't wrap? Also, the "try" example doesn't defer-close "w" in
by kodablah 7y ago
Why is there a defer in the "try" example? To just show wrapping even though the "existing" one doesn't wrap? Also, the "try" example doesn't defer-close "w" in case copy fails. Seems that they aren't the same example.
- ixwt 7y agotry() implicitly returns when there's an error, and sets the error in the case of an error. Then the defer statement would handle the error, as the return is happening.
- kodablah 7y agoI'm saying it doesn't match what "existing" is doing which doesn't wrap the error. If you want comparable examples, they need to be doing the same thing, not one wrapping w/ an Errorf and another not.