← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15114: Exception handling

 

------------------------------------------------------------
revno: 15114
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-29 19:03:48 +0200
message:
  Exception handling
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CrudControllerAdvice.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CrudControllerAdvice.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CrudControllerAdvice.java	2014-04-29 10:15:21 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/CrudControllerAdvice.java	2014-04-29 17:03:48 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.api.controller.exception.NotFoundException;
 import org.hisp.dhis.api.controller.exception.NotFoundForQueryException;
 import org.hisp.dhis.common.DeleteNotAllowedException;
+import org.hisp.dhis.common.IllegalQueryException;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
@@ -93,5 +94,23 @@
         headers.add( "Content-Type", MediaType.TEXT_PLAIN_VALUE );
         
         return new ResponseEntity<String>( ex.getMessage(), headers, HttpStatus.CONFLICT );
-    }    
+    }
+
+    @ExceptionHandler(IllegalQueryException.class)
+    public ResponseEntity<String> handleError( IllegalQueryException ex )
+    {
+        HttpHeaders headers = new HttpHeaders();
+        headers.add( "Content-Type", MediaType.TEXT_PLAIN_VALUE );
+        
+        return new ResponseEntity<String>( ex.getMessage(), headers, HttpStatus.CONFLICT );
+    }
+
+    @ExceptionHandler(IllegalArgumentException.class)
+    public ResponseEntity<String> handleError( IllegalArgumentException ex )
+    {
+        HttpHeaders headers = new HttpHeaders();
+        headers.add( "Content-Type", MediaType.TEXT_PLAIN_VALUE );
+        
+        return new ResponseEntity<String>( ex.getMessage(), headers, HttpStatus.CONFLICT );
+    }
 }