本文整理汇总了Java中org.apache.commons.lang3.exception.ExceptionUtils.rethrow方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtils.rethrow方法的具体用法?Java ExceptionUtils.rethrow怎么用?Java ExceptionUtils.rethrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.exception.ExceptionUtils
的用法示例。
在下文中一共展示了ExceptionUtils.rethrow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readConfig
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* 读取配置
*/
public Map<String, String> readConfig() {
try {
if (!cacheFile.exists()) {
throw new IllegalStateException("不存在缓存文件:" + cacheFile.getPath());
}
InputStream in = null;
try {
in = new FileInputStream(cacheFile);
Properties props = new Properties();
props.load(in);
return propsToMap(props);
} finally {
if (in != null) {
in.close();
}
}
} catch (IOException e) {
return ExceptionUtils.rethrow(e);
}
}
示例2: product
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public Product product(long number) {
try {
return new JdbcSession(this.dBase)
.sql("SELECT * FROM product WHERE id=?")
.set(number)
.select((rset, stmt) -> {
if (!rset.next()) {
throw new IllegalStateException("no product");
}
return create(rset);
});
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例3: storeConfig
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* 缓存配置
*/
public void storeConfig(Map<String, String> properties) {
try {
// 如果缓存文件不存在,则创建
FileUtils.createFileIfAbsent(cacheFile.getPath());
OutputStream out = null;
try {
out = new FileOutputStream(cacheFile);
mapToProps(properties).store(out, "updated at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
} finally {
if (out != null) {
out.close();
}
}
} catch (IOException e) {
ExceptionUtils.rethrow(e);
}
}
示例4: queryConfig
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* 查询配置
*/
public Map<String, String> queryConfig() {
try {
String resultStr = HTTP_CLIENT.execute(request, new BasicResponseHandler());
FindPropertiesResult result = JSON.parseObject(resultStr, FindPropertiesResult.class);
if (result == null) {
throw new RuntimeException("请求配置中心失败");
}
if (!result.isSuccess()) {
throw new RuntimeException("从配置中心读取配置失败:" + result.getMessage());
}
return result.getProperties();
} catch (IOException e) {
return ExceptionUtils.rethrow(e);
}
}
示例5: call
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
/**
* Wrap the body with transaction.
*
* @param body The body to be executed with transaction.
* @return Result of execution.
*/
<T> T call(Function<JdbcSession, T> body) {
JdbcSession session = new JdbcSession(this.dbase);
try {
session.autocommit(false);
T result = body.apply(session);
session.sql("COMMIT").execute();
return result;
} catch (Exception ex) {
try {
session.sql("ROLLBACK").execute();
} catch (Exception e) {
// noop
}
return ExceptionUtils.rethrow(ex);
}
}
示例6: executeInsertTarget
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private void executeInsertTarget(String flow, TargetContext targetContext) {
try {
// 获取流程事务执行器
FlowTxExecutor flowTxExecutor = flowTxHolder.getRequiredFlowTxExecutor(flow);
// 插入目标对象
flowTxExecutor.insertTarget(targetContext);
} catch (Throwable e) {
ExceptionUtils.rethrow(e);
}
}
示例7: publish
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public void publish(Object event) {
try {
eventBus.dispatch(event);
} catch (Throwable e) {
ExceptionUtils.rethrow(e);
}
}
示例8: category
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public Category category(long number) {
try {
new JdbcSession(this.dBase)
.sql("SELECT id FROM category WHERE id=?")
.set(number)
.select(Outcome.NOT_EMPTY);
// exist
return new H2Category(dBase, number);
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例9: iterate
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public List<Product> iterate() {
try {
return new JdbcSession(this.dBase)
.sql("SELECT * FROM product")
.select(new ListOutcome<>(this::create));
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例10: add
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public Category add(String name, Optional<Category> parent) {
try {
return new H2Category(dBase,
new JdbcSession(this.dBase)
.sql("INSERT INTO category (name, parent_id) VALUES (?, ?)")
.set(name)
.set(parent.map(Category::id).orElse(null))
.insert(new SingleOutcome<>(Long.class)));
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例11: desc
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private String desc() {
try {
return new JdbcSession(dBase)
.sql("SELECT desc FROM product WHERE id=?")
.set(this.number)
.select(new SingleOutcome<>(String.class));
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例12: price
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private MonetaryAmount price() {
try {
return FastMoney.of(
new BigDecimal(
new JdbcSession(dBase)
.sql("SELECT price FROM product WHERE id=?")
.set(this.number)
.select(new SingleOutcome<>(String.class))),
"CZK");
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例13: update
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public Product update(String name, String desc, MonetaryAmount price) {
try {
new JdbcSession(dBase)
.sql("UPDATE product SET name=?, desc=?, price=? WHERE id=?")
.set(name)
.set(desc)
.set(price.getNumber())
.set(this.number)
.update(Outcome.VOID);
return new H2Product(dBase, this.number);
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}
示例14: iterate
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
@Override
public List<Product> iterate() {
try {
return new JdbcSession(this.dBase)
.sql("SELECT product_id FROM category_product WHERE category_id = ?")
.set(category.id())
.select(new ListOutcome<>(rSet ->
new H2Product(dBase, rSet.getLong(1))));
} catch (Exception e) {
return ExceptionUtils.rethrow(e);
}
}
示例15: parent
import org.apache.commons.lang3.exception.ExceptionUtils; //导入方法依赖的package包/类
private Optional<Category> parent() {
try {
return Optional.ofNullable(new JdbcSession(dBase)
.sql("SELECT parent_id FROM category WHERE id=?")
.set(this.number)
.select(new SingleOutcome<>(Long.class, true)))
.filter(id -> id > 0) // null value in db
.map(id -> new H2Category(dBase, id));
} catch (SQLException e) {
return ExceptionUtils.rethrow(e);
}
}