use of io.leopard.mvc.trynb.model.ErrorConfig 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.ErrorConfig 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.ErrorConfig in project leopard by tanhaichao.
the class TrynbDaoXmlImpl method parse.
protected List<ErrorConfig> parse(InputStream input) throws IOException, ParserConfigurationException, SAXException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.parse(input);
NodeList nodeList = document.getElementsByTagName("error");
// System.out.println("nodeList:" + nodeList.getLength());
List<ErrorConfig> list = new ArrayList<ErrorConfig>();
int size = nodeList.getLength();
for (int i = 0; i < size; i++) {
Node node = nodeList.item(i);
ErrorConfig errorConfig = this.parseErrorConfig((Element) node);
list.add(errorConfig);
}
input.close();
return list;
}
use of io.leopard.mvc.trynb.model.ErrorConfig in project leopard by tanhaichao.
the class ErrorConfigTest method ErrorConfig.
@Test
public void ErrorConfig() {
ErrorConfig config = new ErrorConfig();
config.setUrl("url");
config.setPage("page");
config.setExceptionConfigList(null);
config.getUrl();
config.getPage();
config.getExceptionConfigList();
}
use of io.leopard.mvc.trynb.model.ErrorConfig in project leopard by tanhaichao.
the class TrynbDaoXmlImplTest method parse.
@Test
public void parse() throws IOException, ParserConfigurationException, SAXException {
InputStream input = this.getClass().getResourceAsStream("trynb.xml");
List<ErrorConfig> list = errorPageDaoXmlImpl.parse(input);
// Json.printList(list, "list");
for (ErrorConfig config : list) {
System.out.println("config:" + config);
}
}
Aggregations