parent
a0998d2edf
commit
3b92f0b834
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue