// Path: Server/src/main/java/com/easychat/model/error/ErrorInfo.java
// public class ErrorInfo {
//     private String error;
//     private String description;
// 
//     public String getError() {
//         return error;
//     }
// 
//     public void setError(String error) {
//         this.error = error;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public ErrorInfo(String error, String description) {
//         this.error = error;
//         this.description = description;
//     }
// }


import com.easychat.model.error.ErrorInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;
package com.easychat.exception;




/**
 * Created by yonah on 15-11-6.
 */
@ControllerAdvice
public class GlobalControllerExceptionHandler {
    static Logger logger = LoggerFactory.getLogger(GlobalControllerExceptionHandler.class);

    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ExceptionHandler(value = NotFoundException.class)
    @ResponseBody
    public ErrorInfo handleNotFound(HttpServletRequest req, NotFoundException ex){
        logger.info("{} not found", req.getRequestURI());
        return new ErrorInfo(ex.getError(), ex.getDescription());
    }
// Path: Server/src/main/java/com/easychat/model/error/ErrorInfo.java
// public class ErrorInfo {
//     private String error;
//     private String description;
// 
//     public String getError() {
//         return error;
//     }
// 
//     public void setError(String error) {
//         this.error = error;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public ErrorInfo(String error, String description) {
//         this.error = error;
//         this.description = description;
//     }
// }


// Path: Server/src/main/java/com/easychat/exception/GlobalControllerExceptionHandler.java
import com.easychat.model.error.ErrorInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import javax.servlet.http.HttpServletRequest;

package com.easychat.exception;




/**
 * Created by yonah on 15-11-6.
 */
@ControllerAdvice
public class GlobalControllerExceptionHandler {
    static Logger logger = LoggerFactory.getLogger(GlobalControllerExceptionHandler.class);

    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ExceptionHandler(value = NotFoundException.class)
    @ResponseBody
    public ErrorInfo handleNotFound(HttpServletRequest req, NotFoundException ex){
        logger.info("{} not found", req.getRequestURI());
        return new ErrorInfo(ex.getError(), ex.getDescription());
    }
    @ResponseStatus(HttpStatus.BAD_REQUEST)