Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gardening] Clean up do catch blocks #1627

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

otaviolima
Copy link
Contributor

  • Remove wildcard pattern matching
  • Refactor catches with empty body
  • Prefer using try? to ignore errors instead of empty catch body
  • Prefer not assigning a variable name

XCTFail("\(error) for \(calendar)")
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the catch not be 2 lines up?

Copy link
Contributor Author

@otaviolima otaviolima Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. I messed up with another change I've made while I was picking the changes to stage before commit. Nice catch :)

Gonna fix and push again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine now.

@spevans
Copy link
Contributor

spevans commented Jul 11, 2018

@swift-ci please test

Copy link
Contributor

@parkera parkera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good pending the tests passing here.

@@ -93,7 +93,7 @@ internal class _HTTPURLProtocol: _NativeProtocol {
case (_, nil):
set(requestBodyLength: .unknown)
}
} catch let e {
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e is used inside the catch block for the errorCode(fileSystemError: e) call so this should be left in

@otaviolima
Copy link
Contributor Author

Fixed the compilation error, tests should pass now.

@spevans
Copy link
Contributor

spevans commented Jul 12, 2018

@swift-ci please test

@otaviolima
Copy link
Contributor Author

Seems that @swift-ci did not start.

@spevans
Copy link
Contributor

spevans commented Jul 12, 2018

XCTFail()
} catch {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to be another issue with the catch being moved down

- Remove wildcard pattern matching
- Refactor catches with empty body
- Prefer using try? to ignore errors instead of empty catch body
- Prefer not assigning a variable name
@otaviolima
Copy link
Contributor Author

Fixed and ran tests locally, it is passing in my env. Sorry for the hassle.

@spevans
Copy link
Contributor

spevans commented Jul 12, 2018

@swift-ci please test

@spevans
Copy link
Contributor

spevans commented Jul 12, 2018

@millenomi
Copy link
Contributor

@swift-ci please test and merge

@swift-ci swift-ci merged commit 8a5c3d8 into swiftlang:master Oct 10, 2018
@otaviolima otaviolima deleted the do-catch-refactor branch October 11, 2018 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants