Added handling error response
This commit is contained in:
		@@ -34,7 +34,7 @@ public class XmlFormatterController implements RestController {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
            requestBody = this.gson.fromJson(request.body(), XMLRequestBody.class);
 | 
					            requestBody = this.gson.fromJson(request.body(), XMLRequestBody.class);
 | 
				
			||||||
        } catch (Exception e) {
 | 
					        } catch (Exception e) {
 | 
				
			||||||
            //requestErrorResponse(response, e);
 | 
					            requestErrorResponse(response, e);
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        String responseString = formatter.formatXML(requestBody.getData());
 | 
					        String responseString = formatter.formatXML(requestBody.getData());
 | 
				
			||||||
@@ -43,4 +43,9 @@ public class XmlFormatterController implements RestController {
 | 
				
			|||||||
        response.body(this.gson.toJson(responseBody));
 | 
					        response.body(this.gson.toJson(responseBody));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    private void requestErrorResponse(Response response, Exception ex) {
 | 
				
			||||||
 | 
					        XMLResponseBody responseBody = new XMLResponseBody(ex.getMessage(), "ERR", "N/A", -1);
 | 
				
			||||||
 | 
					        response.status(400);
 | 
				
			||||||
 | 
					        response.body(this.gson.toJson(responseBody));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user