}
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
errorContext.setErrorCode(toHandleException.getErrorCode());
MessageReference messageReference = toHandleException.getMessageReference();
Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
if (localizedMessage != null) {
errorContext.setMessage(localizedMessage.getText());
errorContext.setLocale(localizedMessage.getLocale());
}
if (toHandleException instanceof ODataHttpException) {
errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
} else if (toHandleException instanceof EntityProviderException) {
errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);