BAEL-5157

* more meaningful exception messages
This commit is contained in:
Ulisses Lima 2022-04-18 10:46:13 -03:00
parent a0998d2edf
commit 3b92f0b834
2 changed files with 3 additions and 3 deletions

View File

@ -34,7 +34,7 @@ public class StocksResource {
@Produces(MediaType.APPLICATION_JSON)
public Response get(@PathParam("ticker") String id) {
Optional<Stock> stock = stocks.findById(id);
stock.orElseThrow(IllegalArgumentException::new);
stock.orElseThrow(() -> new IllegalArgumentException("ticker"));
return Response.ok(stock.get())
.build();

View File

@ -7,7 +7,7 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
public class ServerExceptionMapper implements ExceptionMapper<WebApplicationException> {
public static final String HTTP_405_MESSAGE = "METHOD_NOT_ALLOWED";
public static final String HTTP_405_MESSAGE = "use one of";
@Override
public Response toResponse(final WebApplicationException exception) {
@ -18,7 +18,7 @@ public class ServerExceptionMapper implements ExceptionMapper<WebApplicationExce
switch (status) {
case METHOD_NOT_ALLOWED:
message = HTTP_405_MESSAGE;
message = HTTP_405_MESSAGE + response.getAllowedMethods();
break;
case INTERNAL_SERVER_ERROR:
message = "internal validation - " + exception;