Github user swgkg commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/296#discussion_r29754432
  
    --- Diff: 
components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
 ---
    @@ -453,6 +453,15 @@ public Response addServiceGroup(
                 if (e.getCause().getMessage().contains("already exists")) {
                     return 
Response.status(Response.Status.CONFLICT).entity(new StatusResponseBean(
                             Response.Status.CONFLICT.getStatusCode(), 
"Cartridge group not found")).build();
    +            } else if(e.getCause().getMessage().contains("duplicate 
cartridges")) {
    +                return 
Response.status(Response.Status.BAD_REQUEST).entity(new StatusResponseBean(
    +                        Response.Status.BAD_REQUEST.getStatusCode(), 
"Cartridges duplicated in the group definition")).build();
    +            } else if(e.getCause().getMessage().contains("duplicate 
groups")) {
    +                return 
Response.status(Response.Status.BAD_REQUEST).entity(new StatusResponseBean(
    +                        Response.Status.BAD_REQUEST.getStatusCode(), 
"Groups duplicated in the group definition")).build();
    +            } else if(e.getCause().getMessage().contains("cyclic group")) {
    +                return 
Response.status(Response.Status.BAD_REQUEST).entity(new StatusResponseBean(
    +                        Response.Status.BAD_REQUEST.getStatusCode(), 
"Cyclic group behaviour identified in the group definition")).build();
    --- End diff --
    
    IMO e.getCause().getMessage().contains("") is the not a good way to filter 
out the Status.Can't we return the status code with the exception it self?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to