Skip to content

Commit

Permalink
Throw bad request exception instead of returning ResponseEntity
Browse files Browse the repository at this point in the history
  • Loading branch information
forus committed Jun 26, 2024
1 parent 6606d98 commit d3cf299
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.server.ResponseStatusException;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -104,7 +105,7 @@ public ResponseEntity<VirtualStudy> publishVirtualStudyData(
virtualStudyDataToPublish.setTypeOfCancerId(typeOfCancerId);
} catch (CancerTypeNotFoundException e) {
LOG.error("No cancer type with id={} were found.", typeOfCancerId);
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The cancer type is not valid.", e);
}
}
if (pmid != null) {
Expand Down

0 comments on commit d3cf299

Please sign in to comment.