use of io.github.ihongs.HongsException in project HongsCORE by ihongs.
the class Proclet method doAction.
@Override
public void doAction(Core core, ActionHelper ah) throws ServletException, IOException {
HttpServletRequest req = ah.getRequest();
HttpServletResponse rsp = ah.getResponse();
try {
this._jspService(new Request(req), rsp);
} catch (ServletException ex) {
Throwable ax = ex.getCause();
if (ax == null) {
ax = ex;
}
if (ax instanceof HongsCause) {
ah.fault((HongsCause) ax);
} else {
ah.fault(new HongsException(ax));
}
} catch (RuntimeException ax) {
if (ax instanceof HongsCause) {
ah.fault((HongsCause) ax);
} else {
ah.fault(new HongsException(ax));
}
}
}
use of io.github.ihongs.HongsException in project HongsCORE by ihongs.
the class Batch method close.
@Override
public void close() {
if (!servs.isShutdown()) {
servs.shutdownNow();
}
if (back == null) {
if (!tasks.isEmpty()) {
CoreLogger.error("There has {} task(s) not run.", tasks.size());
}
return;
}
/**
* 将缓冲区滞留的任务写回 tasks
* 即使重启后 servs 数量改变也没有关系
*/
Collection<T> c = new ArrayList();
for (Collection<T> taskz : cache) {
c.addAll(taskz);
taskz.clear();
}
c.addAll(tasks);
tasks.clear();
tasks.addAll(c);
File file;
file = back;
back = null;
if (!tasks.isEmpty()) {
try {
save(file);
CoreLogger.trace("There has {} task(s) not run, save to '{}'.", tasks.size(), back.getPath());
} catch (HongsException ex) {
CoreLogger.error(ex);
}
} else if (file.exists()) {
file.delete();
}
}
use of io.github.ihongs.HongsException in project HongsCORE by ihongs.
the class Table method valiException.
private HongsException valiException(int code, String error, String fieldName, String... otherParams) {
List<String> trans = new ArrayList(otherParams.length + 2);
trans.add(db.name + "." + name);
trans.add(/*the*/
fieldName);
trans.addAll(Arrays.asList(otherParams));
return new HongsException(code, error + " (Table:" + name + ")").setLocalizedOptions(trans.toArray(new String[] {}));
}
use of io.github.ihongs.HongsException in project HongsCORE by ihongs.
the class Loop method next.
@Override
public Map next() {
// 判断是否到达末尾
if (!hasNext()) {
this.close();
return null;
}
il = null;
// 获取当前字段类型
try {
// getMetaData();
getTypeDict();
} catch (HongsException ex) {
this.close();
throw ex.toExemption();
}
// 获取行内每列数据
try {
int i = 0;
Map<String, Object> row = new LinkedHashMap();
if (ib) {
for (Map.Entry<String, Class> et : td.entrySet()) {
// row.put(et.getKey() , rs.getString(++ i /* No Type */ ));
Dict.put(row, rs.getString(++i), (Object[]) et.getKey().split("\\."));
}
} else {
for (Map.Entry<String, Class> et : td.entrySet()) {
// row.put(et.getKey() , rs.getObject(++ i, et.getValue()));
Dict.put(row, rs.getObject(++i), (Object[]) et.getKey().split("\\."));
}
}
return row;
} catch (SQLException ex) {
this.close();
throw new HongsExemption(1153, ex);
}
}
use of io.github.ihongs.HongsException in project HongsCORE by ihongs.
the class Simple method open.
@Override
public Connection open() throws HongsException {
try {
if (connection == null || connection.isClosed()) {
connection = open(jdbc, path, info);
CoreLogger.trace("DB: Connect to '{}' by simple mode: {} {}", name, jdbc, path);
}
return connection;
} catch (SQLException ex) {
throw new HongsException(1024, ex);
} catch (ClassNotFoundException ex) {
throw new HongsException(1024, ex);
}
}
Aggregations