Skip to content

Commit

Permalink
Refactored exception #3789
Browse files Browse the repository at this point in the history
  • Loading branch information
lorriborri committed Jan 16, 2025
1 parent 6036536 commit 53d25dd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.mercedesbenz.sechub.domain.administration.user.User;
import com.mercedesbenz.sechub.domain.administration.user.UserRepository;
import com.mercedesbenz.sechub.sharedkernel.Step;
import com.mercedesbenz.sechub.sharedkernel.error.InternalServerError;
import com.mercedesbenz.sechub.sharedkernel.error.NotFoundException;
import com.mercedesbenz.sechub.sharedkernel.logging.AuditLogService;
import com.mercedesbenz.sechub.sharedkernel.messaging.DomainMessage;
Expand Down Expand Up @@ -81,7 +82,8 @@ private void assertUserAllowedCancelJob(UUID jobUUID, String userId) {
Set<Project> projects = user.getProjects();

if (projects == null) {
throw new IllegalStateException("Projects fore user {} are null." + userId);
LOG.debug("Projects for user {} are null.", userId);
throw new InternalServerError("Projects fore user %s are null.".formatted(userId));
}

boolean isForbidden = projects.stream().noneMatch(project -> project.getId().equals(jobInfo.getProjectId()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mercedesbenz.sechub.sharedkernel.error;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public class InternalServerError extends RuntimeException {
private static final long serialVersionUID = 8392017456124983765L;

public InternalServerError() {
this("An internal server error occurred!");
}

public InternalServerError(String message) {
super(message);
}
}

0 comments on commit 53d25dd

Please sign in to comment.