Commit 644664b0 authored by neelesh thakur's avatar neelesh thakur
Browse files

Merge branch 'master' into wait-for-active-shards

parents 114fd007 b28f0adf
Pipeline #100622 passed with stages
in 41 minutes and 37 seconds
......@@ -20,6 +20,7 @@ import javassist.NotFoundException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
......@@ -74,6 +75,12 @@ public class GlobalExceptionMapperCore extends ResponseEntityExceptionHandler {
}
}
@ExceptionHandler(SchemaProcessingException.class)
public ResponseEntity<Object> handleSchemaProcessingException(SchemaProcessingException e) {
return this.getErrorResponse(
new AppException(HttpStatus.BAD_REQUEST.value(), "Error processing schema.", e.getMessage(), e));
}
@ExceptionHandler(Exception.class)
protected ResponseEntity<Object> handleGeneralException(Exception e) {
return this.getErrorResponse(
......
......@@ -23,6 +23,7 @@ import org.mockito.Mock;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.RequestStatus;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.AccessDeniedException;
......@@ -107,4 +108,12 @@ public class GlobalExceptionMapperCoreTest {
ResponseEntity response = this.sut.handleIOException(ioException);
assertEquals(HttpStatus.SC_SERVICE_UNAVAILABLE, response.getStatusCodeValue());
}
@Test
public void should_returnAppException_when_SchemaProcessingExceptionIsThrown() {
SchemaProcessingException schemaProcessingException = new SchemaProcessingException("error processing schema");
ResponseEntity response = this.sut.handleSchemaProcessingException(schemaProcessingException);
assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatusCodeValue());
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment