mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-01 11:05:56 +01:00
Fix media type for validation error
This commit is contained in:
@@ -46,18 +46,7 @@ class BackendErrorNotification extends React.Component<Props> {
|
|||||||
const { error, t } = this.props;
|
const { error, t } = this.props;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>
|
{this.renderContext(error)}
|
||||||
<strong>{t("errors.context")}</strong>
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
{error.context.map((context, index) => {
|
|
||||||
return (
|
|
||||||
<li key={index}>
|
|
||||||
<strong>{context.type}:</strong> {context.id}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ul>
|
|
||||||
{this.renderMoreInformationLink(error)}
|
{this.renderMoreInformationLink(error)}
|
||||||
<div className="level is-size-7">
|
<div className="level is-size-7">
|
||||||
<div className="left">
|
<div className="left">
|
||||||
@@ -71,6 +60,26 @@ class BackendErrorNotification extends React.Component<Props> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
renderContext = (error: BackendError) => {
|
||||||
|
if (error.context) {
|
||||||
|
return <>
|
||||||
|
<p>
|
||||||
|
<strong>{t("errors.context")}</strong>
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
{error.context.map((context, index) => {
|
||||||
|
return (
|
||||||
|
<li key={index}>
|
||||||
|
<strong>{context.type}:</strong> {context.id}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</>;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
renderMoreInformationLink = (error: BackendError) => {
|
renderMoreInformationLink = (error: BackendError) => {
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
if (error.url) {
|
if (error.url) {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package sonia.scm.api.v2;
|
|||||||
|
|
||||||
import org.jboss.resteasy.api.validation.ResteasyViolationException;
|
import org.jboss.resteasy.api.validation.ResteasyViolationException;
|
||||||
import sonia.scm.api.v2.resources.ResteasyViolationExceptionToErrorDtoMapper;
|
import sonia.scm.api.v2.resources.ResteasyViolationExceptionToErrorDtoMapper;
|
||||||
|
import sonia.scm.web.VndMediaType;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
@@ -23,7 +23,7 @@ public class ResteasyValidationExceptionMapper implements ExceptionMapper<Restea
|
|||||||
public Response toResponse(ResteasyViolationException exception) {
|
public Response toResponse(ResteasyViolationException exception) {
|
||||||
return Response
|
return Response
|
||||||
.status(Response.Status.BAD_REQUEST)
|
.status(Response.Status.BAD_REQUEST)
|
||||||
.type(MediaType.APPLICATION_JSON_TYPE)
|
.type(VndMediaType.ERROR_TYPE)
|
||||||
.entity(mapper.map(exception))
|
.entity(mapper.map(exception))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package sonia.scm.api.v2;
|
|||||||
|
|
||||||
import sonia.scm.ScmConstraintViolationException;
|
import sonia.scm.ScmConstraintViolationException;
|
||||||
import sonia.scm.api.v2.resources.ScmViolationExceptionToErrorDtoMapper;
|
import sonia.scm.api.v2.resources.ScmViolationExceptionToErrorDtoMapper;
|
||||||
|
import sonia.scm.web.VndMediaType;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.ext.ExceptionMapper;
|
import javax.ws.rs.ext.ExceptionMapper;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
@@ -23,7 +23,7 @@ public class ScmConstraintValidationExceptionMapper implements ExceptionMapper<S
|
|||||||
public Response toResponse(ScmConstraintViolationException exception) {
|
public Response toResponse(ScmConstraintViolationException exception) {
|
||||||
return Response
|
return Response
|
||||||
.status(Response.Status.BAD_REQUEST)
|
.status(Response.Status.BAD_REQUEST)
|
||||||
.type(MediaType.APPLICATION_JSON_TYPE)
|
.type(VndMediaType.ERROR_TYPE)
|
||||||
.entity(mapper.map(exception))
|
.entity(mapper.map(exception))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user