Skip to content

Commit f291f48

Browse files
refactor: Rename exception handling methods to better reflect intent
1 parent a3b9ee0 commit f291f48

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/main/java/org/kohsuke/github/EnterpriseManagedSupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.logging.Logger;
99

1010
/**
11-
* Utility class for helping with operation for enterprise managed resources.
11+
* Utility class for helping with operations for enterprise managed resources.
1212
*
1313
* @author Miguel Esteban Gutiérrez
1414
*/
@@ -26,7 +26,7 @@ private EnterpriseManagedSupport(GHOrganization organization) {
2626
this.organization = organization;
2727
}
2828

29-
Optional<GHIOException> handleException(final HttpException he, final String scenario) {
29+
Optional<GHIOException> filterException(final HttpException he, final String scenario) {
3030
if (he.getResponseCode() == 400) {
3131
final String responseMessage = he.getMessage();
3232
try {
@@ -46,10 +46,10 @@ Optional<GHIOException> handleException(final HttpException he, final String sce
4646
return Optional.empty();
4747
}
4848

49-
Optional<GHException> handleException(final GHException e) {
49+
Optional<GHException> filterException(final GHException e) {
5050
if (e.getCause() instanceof HttpException) {
5151
final HttpException he = (HttpException) e.getCause();
52-
return handleException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
52+
return filterException(he, COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS)
5353
.map(translated -> new GHException(COULD_NOT_RETRIEVE_ORGANIZATION_EXTERNAL_GROUPS, translated));
5454
}
5555
return Optional.empty();

src/main/java/org/kohsuke/github/GHExternalGroupIterable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public boolean hasNext() {
6060
try {
6161
return base.hasNext();
6262
} catch (final GHException e) {
63-
throw EnterpriseManagedSupport.forOrganization(owner).handleException(e).orElse(e);
63+
throw EnterpriseManagedSupport.forOrganization(owner).filterException(e).orElse(e);
6464
}
6565
}
6666

src/main/java/org/kohsuke/github/GHOrganization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public GHExternalGroup getExternalGroup(final long groupId) throws IOException {
240240
.wrapUp(this);
241241
} catch (final HttpException e) {
242242
throw EnterpriseManagedSupport.forOrganization(this)
243-
.handleException(e, "Could not retrieve organization external group")
243+
.filterException(e, "Could not retrieve organization external group")
244244
.orElse(e);
245245
}
246246
}

src/main/java/org/kohsuke/github/GHTeam.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ public List<GHExternalGroup> getExternalGroups() throws IOException {
448448
.getGroups();
449449
} catch (final HttpException e) {
450450
throw EnterpriseManagedSupport.forOrganization(getOrganization())
451-
.handleException(e, "Could not retrieve team external groups")
451+
.filterException(e, "Could not retrieve team external groups")
452452
.orElse(e);
453453
}
454454
}
@@ -489,7 +489,7 @@ public GHExternalGroup connectToExternalGroup(final long group_id) throws IOExce
489489
.wrapUp(getOrganization());
490490
} catch (final HttpException e) {
491491
throw EnterpriseManagedSupport.forOrganization(getOrganization())
492-
.handleException(e, "Could not connect team to external group")
492+
.filterException(e, "Could not connect team to external group")
493493
.orElse(e);
494494
}
495495
}

src/test/java/org/kohsuke/github/EnterpriseManagedSupportTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void testIgnoreNonHttpException() throws IOException {
3737
final GHException inputException = new GHException("Test", inputCause);
3838

3939
final Optional<GHException> maybeException = EnterpriseManagedSupport.forOrganization(org)
40-
.handleException(inputException);
40+
.filterException(inputException);
4141

4242
assertThat(maybeException.isPresent(), is(false));
4343
}
@@ -59,7 +59,7 @@ public void testIgnoreNonBadRequestExceptions() throws IOException {
5959
final GHException inputException = new GHException("Test", inputCause);
6060

6161
final Optional<GHException> maybeException = EnterpriseManagedSupport.forOrganization(org)
62-
.handleException(inputException);
62+
.filterException(inputException);
6363

6464
assertThat(maybeException.isPresent(), is(false));
6565
}
@@ -78,7 +78,7 @@ public void testIgnoreBadRequestsWithUnparseableJson() throws IOException {
7878
final GHException inputException = new GHException("Test", inputCause);
7979

8080
final Optional<GHException> maybeException = EnterpriseManagedSupport.forOrganization(org)
81-
.handleException(inputException);
81+
.filterException(inputException);
8282

8383
assertThat(maybeException.isPresent(), is(false));
8484
}
@@ -97,7 +97,7 @@ public void testIgnoreBadRequestsWithUnknownErrorMessage() throws IOException {
9797
final GHException inputException = new GHException("Test", inputCause);
9898

9999
final Optional<GHException> maybeException = EnterpriseManagedSupport.forOrganization(org)
100-
.handleException(inputException);
100+
.filterException(inputException);
101101

102102
assertThat(maybeException.isPresent(), is(false));
103103
}
@@ -119,7 +119,7 @@ public void testHandleEmbeddedNotPartOfExternallyManagedEnterpriseHttpException(
119119
final GHException inputException = new GHException("Test", inputCause);
120120

121121
final Optional<GHException> maybeException = EnterpriseManagedSupport.forOrganization(org)
122-
.handleException(inputException);
122+
.filterException(inputException);
123123

124124
assertThat(maybeException.isPresent(), is(true));
125125

@@ -162,7 +162,7 @@ public void testHandleTeamCannotBeExternallyManagedHttpException() throws IOExce
162162
org.getUrl().toString());
163163

164164
final Optional<GHIOException> maybeException = EnterpriseManagedSupport.forOrganization(org)
165-
.handleException(inputException, "Scenario");
165+
.filterException(inputException, "Scenario");
166166

167167
assertThat(maybeException.isPresent(), is(true));
168168

0 commit comments

Comments
 (0)