Skip to content

Commit f653206

Browse files
Catch umbrella exception instead of GitHubNavigatorException
Doing this because the exception thrown by the navigator was a edu.stanford.protege.commitnavigator.exceptions.RepositoryException
1 parent f38a6e5 commit f653206

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/main/java/edu/stanford/protege/github/cloneservice/CreateProjectHistoryCommandHandler.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.slf4j.Logger;
2727
import org.slf4j.LoggerFactory;
2828
import org.springframework.beans.factory.annotation.Qualifier;
29+
import org.springframework.core.NestedExceptionUtils;
2930
import reactor.core.publisher.Mono;
3031

3132
@WebProtegeHandler
@@ -121,6 +122,7 @@ private void startAsyncProcessing(
121122
fireStoreSucceeded(projectId, operationId, branchCoordinates);
122123
fireCreateProjectHistoryFromGitHubRepoSucceeded(operationId, projectId, documentLocation);
123124
} else {
125+
logger.info("{} {} Failed to create project history {}", operationId, projectId, t.getMessage());
124126
// Terminal overarching error
125127
fireCreateProjectHistoryFromGitHubRepoFailed(operationId, projectId, t);
126128
}
@@ -143,7 +145,7 @@ private CompletableFuture<GitHubRepository> cloneRepositoryAsync(
143145
branchCoordinates.repositoryUrl());
144146
var workingDirectory = getLocalWorkingDirectory(userId, projectId);
145147
return cloneGitHubRepository(branchCoordinates, workingDirectory);
146-
} catch (GitHubNavigatorException e) {
148+
} catch (Exception e) {
147149
logger.error(
148150
"{} {} Failed to clone GitHub repository {}",
149151
projectId,
@@ -225,8 +227,9 @@ private void fireCloneFailed(
225227
EventId eventId,
226228
BranchCoordinates branchCoordinates,
227229
Throwable t) {
230+
var mostSpecificCause = NestedExceptionUtils.getMostSpecificCause(t);
228231
eventDispatcher.dispatchEvent(
229-
new CloneRepositoryFailedEvent(projectId, operationId, eventId, branchCoordinates, t.getMessage()));
232+
new CloneRepositoryFailedEvent(projectId, operationId, eventId, branchCoordinates, mostSpecificCause.getMessage()));
230233
}
231234

232235
private void fireCloneSucceeded(
@@ -245,8 +248,9 @@ private void fireGenerateFailed(
245248
EventId eventId,
246249
BranchCoordinates branchCoordinates,
247250
Throwable t) {
251+
var mostSpecificCause = NestedExceptionUtils.getMostSpecificCause(t);
248252
eventDispatcher.dispatchEvent(new GenerateProjectHistoryFailedEvent(
249-
projectId, operationId, eventId, branchCoordinates, t.getMessage()));
253+
projectId, operationId, eventId, branchCoordinates, mostSpecificCause.getMessage()));
250254
}
251255

252256
private void fireGenerateSucceeded(
@@ -260,8 +264,9 @@ private void fireStoreFailed(
260264
CreateProjectHistoryOperationId operationId,
261265
BranchCoordinates branchCoordinates,
262266
Throwable t) {
267+
var mostSpecificCause = NestedExceptionUtils.getMostSpecificCause(t);
263268
eventDispatcher.dispatchEvent(new StoreProjectHistoryFailedEvent(
264-
projectId, operationId, EventId.generate(), branchCoordinates, t.getMessage()));
269+
projectId, operationId, EventId.generate(), branchCoordinates, mostSpecificCause.getMessage()));
265270
}
266271

267272
private void fireStoreSucceeded(
@@ -272,8 +277,10 @@ private void fireStoreSucceeded(
272277

273278
private void fireCreateProjectHistoryFromGitHubRepoFailed(
274279
CreateProjectHistoryOperationId operationId, ProjectId projectId, Throwable t) {
280+
logger.info("{} {} Firing CreateProjectHistoryFailedEvent: {}", projectId, operationId, t.getMessage());
281+
var mostSpecificCause = NestedExceptionUtils.getMostSpecificCause(t);
275282
eventDispatcher.dispatchEvent(
276-
new CreateProjectHistoryFailedEvent(EventId.generate(), operationId, projectId, t.getMessage()));
283+
new CreateProjectHistoryFailedEvent(EventId.generate(), operationId, projectId, mostSpecificCause.getMessage()));
277284
}
278285

279286
private void fireCreateProjectHistoryFromGitHubRepoSucceeded(

0 commit comments

Comments
 (0)