use of io.leopard.mvc.trynb.model.ExceptionConfig in project leopard by tanhaichao.
the class TrynbDaoXmlImpl method parseErrorConfig.
protected ErrorConfig parseErrorConfig(Element element) {
String url = element.getAttribute("url");
String page = element.getAttribute("page");
List<ExceptionConfig> exceptionConfigList = new ArrayList<ExceptionConfig>();
NodeList nodeList = element.getElementsByTagName("exception");
int size = nodeList.getLength();
for (int i = 0; i < size; i++) {
Node node = nodeList.item(i);
ExceptionConfig exceptionConfig = this.parseExceptionConfig((Element) node);
exceptionConfigList.add(exceptionConfig);
}
ErrorConfig errorConfig = new ErrorConfig();
errorConfig.setUrl(url);
errorConfig.setPage(page);
errorConfig.setExceptionConfigList(exceptionConfigList);
return errorConfig;
}
use of io.leopard.mvc.trynb.model.ExceptionConfig in project leopard by tanhaichao.
the class TrynbApiImpl method parse.
@Override
public TrynbInfo parse(TrynbLogger trynbLogger, HttpServletRequest request, String uri, Exception exception) {
ErrorConfig errorConfig = trynbDao.find(uri);
if (exception instanceof MethodArgumentTypeMismatchException) {
MethodArgumentTypeMismatchException e2 = (MethodArgumentTypeMismatchException) exception;
Exception e = (Exception) e2.getCause().getCause();
if (e != null) {
exception = e;
} else {
exception = (Exception) e2.getCause();
}
}
ExceptionConfig exceptionConfig = this.find(errorConfig, exception);
TrynbInfo trynbInfo = new TrynbInfo();
String message;
if (exceptionConfig == null || StringUtils.isEmpty(exceptionConfig.getMessage())) {
message = parseMessage(trynbInfo, exception);
} else {
message = exceptionConfig.getMessage();
trynbInfo.setTrynbMessage(true);
}
String statusCode = this.parseStatusCode(trynbLogger, exceptionConfig, request, uri, exception);
trynbInfo.setPage(errorConfig.getPage());
trynbInfo.setMessage(message);
trynbInfo.setException(exception);
trynbInfo.setStatusCode(statusCode);
return trynbInfo;
}
use of io.leopard.mvc.trynb.model.ExceptionConfig in project leopard by tanhaichao.
the class TrynbApiImpl method find.
protected ExceptionConfig find(ErrorConfig errorConfig, Exception exception) {
List<ExceptionConfig> exceptionConfigList = errorConfig.getExceptionConfigList();
String exceptionClassName = exception.getClass().getName();
for (ExceptionConfig exceptionConfig : exceptionConfigList) {
boolean match = match(exceptionConfig.getType(), exceptionClassName);
if (match) {
return exceptionConfig;
}
}
return null;
}
use of io.leopard.mvc.trynb.model.ExceptionConfig in project leopard by tanhaichao.
the class TrynbDaoXmlImpl method parseExceptionConfig.
protected ExceptionConfig parseExceptionConfig(Element element) {
String type = element.getAttribute("type");
String statusCode = element.getAttribute("statusCode").trim();
String message = element.getAttribute("message");
String log = element.getAttribute("log");
ExceptionConfig exceptionConfig = new ExceptionConfig();
exceptionConfig.setType(type);
exceptionConfig.setMessage(message);
exceptionConfig.setStatusCode(statusCode);
exceptionConfig.setLog(log);
return exceptionConfig;
}
Aggregations