Create error response for concurrent modifications

This commit is contained in:
René Pfeuffer
2018-10-25 13:48:00 +02:00
parent bda5b41271
commit d185743ef0
10 changed files with 57 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
package sonia.scm.api.rest;
import sonia.scm.ConcurrentModificationException;
import sonia.scm.api.v2.resources.ErrorDto;
import sonia.scm.web.VndMediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
@@ -10,6 +12,6 @@ import javax.ws.rs.ext.Provider;
public class ConcurrentModificationExceptionMapper implements ExceptionMapper<ConcurrentModificationException> {
@Override
public Response toResponse(ConcurrentModificationException exception) {
return Response.status(Response.Status.CONFLICT).build();
return Response.status(Response.Status.CONFLICT).entity(ErrorDto.from(exception)).type(VndMediaType.ERROR_TYPE).build();
}
}