Skip to content

Commit 008bcf6

Browse files
committed
refactor: remove standalone BadRequestException
reason: SteveException has similar extending classes/exception. having this exception there makes more sense wrt. cohesion.
1 parent 49026fe commit 008bcf6

File tree

4 files changed

+11
-31
lines changed

4 files changed

+11
-31
lines changed

src/main/java/de/rwth/idsg/steve/SteveException.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,11 @@ public NotFound(String message) {
7373
super(message);
7474
}
7575
}
76+
77+
public static class BadRequest extends SteveException {
78+
79+
public BadRequest(String message) {
80+
super(message);
81+
}
82+
}
7683
}

src/main/java/de/rwth/idsg/steve/web/api/ApiControllerAdvice.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import de.rwth.idsg.steve.SteveException;
2222
import de.rwth.idsg.steve.web.DateTimeEditor;
23-
import de.rwth.idsg.steve.web.api.exception.BadRequestException;
2423
import lombok.Data;
2524
import lombok.extern.slf4j.Slf4j;
2625
import org.joda.time.DateTime;
@@ -74,9 +73,9 @@ public ApiErrorResponse handleAlreadyExistsException(HttpServletRequest req, Ste
7473
return createResponse(url, HttpStatus.UNPROCESSABLE_ENTITY, exception.getMessage());
7574
}
7675

77-
@ExceptionHandler(BadRequestException.class)
76+
@ExceptionHandler(SteveException.BadRequest.class)
7877
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
79-
public ApiErrorResponse handleBadRequestException(HttpServletRequest req, BadRequestException exception) {
78+
public ApiErrorResponse handleBadRequestException(HttpServletRequest req, SteveException.BadRequest exception) {
8079
String url = req.getRequestURL().toString();
8180
log.error("Request: {} raised following exception.", url, exception);
8281
return createResponse(url, HttpStatus.BAD_REQUEST, exception.getMessage());

src/main/java/de/rwth/idsg/steve/web/api/TransactionsRestController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
package de.rwth.idsg.steve.web.api;
2020

21+
import de.rwth.idsg.steve.SteveException;
2122
import de.rwth.idsg.steve.repository.TransactionRepository;
2223
import de.rwth.idsg.steve.repository.dto.Transaction;
2324
import de.rwth.idsg.steve.web.api.ApiControllerAdvice.ApiErrorResponse;
24-
import de.rwth.idsg.steve.web.api.exception.BadRequestException;
2525
import de.rwth.idsg.steve.web.dto.TransactionQueryForm;
2626
import io.swagger.v3.oas.annotations.Operation;
2727
import io.swagger.v3.oas.annotations.media.Content;
@@ -75,7 +75,7 @@ public List<Transaction> get(@Valid @ParameterObject TransactionQueryForm.Transa
7575
log.debug("Read request for query: {}", params);
7676

7777
if (params.isReturnCSV()) {
78-
throw new BadRequestException("returnCSV=true is not supported for API calls");
78+
throw new SteveException.BadRequest("returnCSV=true is not supported for API calls");
7979
}
8080

8181
var response = transactionRepository.getTransactions(params);

src/main/java/de/rwth/idsg/steve/web/api/exception/BadRequestException.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)