Commit 2f51730a authored by neo's avatar neo

[dev] add exception printstatck

parent b31299b6
......@@ -19,12 +19,16 @@ public class AtmsExceptionHandler extends ResponseEntityExceptionHandler {
protected ResponseEntity<Object> handleExceptions(Exception ex) throws ServiceException {
logger.error("Rest Exception!", ex);
if (ex instanceof ApplicationException) {
ex.printStackTrace();
return handleApplicationException((ApplicationException) ex);
} else if (ex instanceof ServiceException) {
ex.printStackTrace();
return handleServiceException((ServiceException) ex);
} else if (ex instanceof ApiException) {
ex.printStackTrace();
return ((ApiException) ex).handle();
} else {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
......
......@@ -11,4 +11,5 @@ public class Exceptions {
public static final ApiException EMPTY_PRIODDATE_PARAM = new BadParameterException("period data is empty");
public static final ApiException NOT_FOUND_REPORT_EXCEPTION = new NotFoundException("not found report");
public static final ApiException REPORT_HAS_COMMIT_EXCEPTION = new AlreadyExistsException("report approval has commit");
public static final ApiException SERVER_ERROR_EXCEPTION= new ServerErrorException("server error exception");
}
package pwc.taxtech.atms.exception;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
public class ServerErrorException extends ApiException {
public ServerErrorException() {
super();
}
public ServerErrorException(String message) {
super(message);
}
public ServerErrorException(String message, Throwable cause) {
super(message, cause);
}
public ServerErrorException(Throwable cause) {
super(cause);
}
@Override
public <Object> ResponseEntity handle() {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
}
......@@ -25,6 +25,8 @@ import pwc.taxtech.atms.vat.entity.PeriodReportExample;
import java.util.*;
import static pwc.taxtech.atms.exception.Exceptions.SERVER_ERROR_EXCEPTION;
@Service
public class ApprovalService {
private static Logger logger = LoggerFactory.getLogger(ApprovalService.class);
......@@ -88,7 +90,7 @@ public class ApprovalService {
periodApproveMapper.insert(pa);
} else {
logger.warn("task must not null or size gt 1");
logger.warn("task must not null or size eq 1");
}
}
......
Markdown is supported
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