Skip to content

Commit 615e384

Browse files
committed
Replace SolverException with ResourceNotFoundException for improved error handling in user settings and application retrieval
1 parent f163976 commit 615e384

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

solver-common/src/main/java/com/solver/SolverController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public CompletableFuture<ResponseEntity<String>> getUserSettings(@PathVariable("
6666
return dbService.getUserSettings(userId)
6767
.thenApply(optionalSettings -> optionalSettings
6868
.map(ResponseEntity::ok)
69-
.orElseThrow(() -> new SolverException("User settings not found for userId: " + userId)));
69+
.orElseThrow(() -> new ResourceNotFoundException("User settings not found for userId: " + userId)));
7070
}
7171

7272
@GetMapping("/users/{userId}/applications")
@@ -75,7 +75,7 @@ public CompletableFuture<ResponseEntity<List<Map<String, Object>>>> getApplicati
7575
return dbService.getApplications(userId)
7676
.thenApply(applications -> {
7777
if (applications.isEmpty()) {
78-
throw new SolverException("Applications not found for userId: " + userId);
78+
throw new ResourceNotFoundException("Applications not found for userId: " + userId);
7979
}
8080
return ResponseEntity.ok(applications);
8181
});
@@ -86,27 +86,27 @@ public CompletableFuture<ResponseEntity<String>> getApplicationStatus(@PathVaria
8686
logger.debug("Getting application status for id: {}", applicationId);
8787

8888
if (applicationId <= 0) {
89-
throw new SolverException("Invalid applicationId: " + applicationId);
89+
throw new ResourceNotFoundException("Invalid applicationId: " + applicationId);
9090
}
9191

9292
return dbService.getApplicationStatus(applicationId)
9393
.thenApply(optionalStatus -> optionalStatus
9494
.map(ResponseEntity::ok)
95-
.orElseThrow(() -> new SolverException("Application status not found for applicationId: " + applicationId)));
95+
.orElseThrow(() -> new ResourceNotFoundException("Application not found for applicationId: " + applicationId)));
9696
}
9797

9898
@GetMapping("/applications/{applicationId}/results")
9999
public CompletableFuture<ResponseEntity<List<Map<String, Object>>>> getResults(@PathVariable("applicationId") int applicationId) {
100100
logger.debug("Getting results for applicationId: {}", applicationId);
101101

102102
if (applicationId <= 0) {
103-
throw new SolverException("Invalid applicationId: " + applicationId);
103+
throw new ResourceNotFoundException("Invalid applicationId: " + applicationId);
104104
}
105105

106106
return dbService.getResults(applicationId)
107107
.thenApply(results -> {
108108
if (results.isEmpty()) {
109-
throw new SolverException("Results not found for applicationId: " + applicationId);
109+
throw new ResourceNotFoundException("Results not found for applicationId: " + applicationId);
110110
}
111111
return ResponseEntity.ok(results);
112112
});

0 commit comments

Comments
 (0)