[OLINGO-1256]Error code improvements
This commit is contained in:
parent
aaff527dcd
commit
a93d49c1aa
|
@ -132,7 +132,11 @@ public class ODataExceptionHelper {
|
|||
}
|
||||
|
||||
public static ODataServerError createServerErrorObject(final ODataLibraryException e, final Locale requestedLocale) {
|
||||
return basicTranslatedError(e, requestedLocale);
|
||||
ODataServerError serverError = basicTranslatedError(e, requestedLocale);
|
||||
if(e instanceof SerializerException || e instanceof DeserializerException){
|
||||
serverError.setStatusCode(HttpStatusCode.BAD_REQUEST.getStatusCode());
|
||||
}
|
||||
return serverError;
|
||||
}
|
||||
|
||||
public static ODataServerError createServerErrorObject(final ODataApplicationException e) {
|
||||
|
|
|
@ -79,6 +79,16 @@ public class ExceptionHelperTest {
|
|||
checkStatusCode(serverError, HttpStatusCode.BAD_REQUEST, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void libraryExceptionLeadToBadRequest() {
|
||||
ODataLibraryException e = new SerializerException(DEV_MSG, SerializerException.MessageKeys.MISSING_PROPERTY);
|
||||
ODataServerError serverError = ODataExceptionHelper.createServerErrorObject(e, null);
|
||||
checkStatusCode(serverError, HttpStatusCode.BAD_REQUEST, e);
|
||||
e = new SerializerException(DEV_MSG, DeserializerException.MessageKeys.DUPLICATE_PROPERTY);
|
||||
serverError = ODataExceptionHelper.createServerErrorObject(e, null);
|
||||
checkStatusCode(serverError, HttpStatusCode.BAD_REQUEST, e);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contentNegotiatorExceptionMustLeadToNotAcceptable() {
|
||||
|
|
Loading…
Reference in New Issue