use of org.rx.exception.ExceptionHandler in project rxlib by RockyLOMO.
the class CoreTester method exceptionHandle.
@ErrorCode
@ErrorCode(cause = IllegalArgumentException.class)
@Test
public void exceptionHandle() {
ExceptionHandler handler = ExceptionHandler.INSTANCE;
handler.log(new InvalidException("test error"));
System.out.println(handler.queryTraces(null, null, null));
String err = "ERR";
ApplicationException ex = new ApplicationException(values(err));
assert eq(ex.getFriendlyMessage(), "Test error code, value=" + err);
ex = new ApplicationException(values(err), new IllegalArgumentException());
assert eq(ex.getFriendlyMessage(), "Test IAException, value=" + err);
$<IllegalArgumentException> out = $();
assert ex.tryGet(out, IllegalArgumentException.class);
String errCode = "ERR_CODE";
ex = new ApplicationException(UserManager.BizCode.USER_NOT_FOUND, values(errCode));
assert eq(ex.getFriendlyMessage(), "User " + errCode + " not found");
ex = new ApplicationException(UserManager.BizCode.COMPUTE_FAIL, values(errCode));
assert eq(ex.getFriendlyMessage(), "Compute user level error " + errCode);
try {
Reflects.changeType("x", Date.class);
} catch (InvalidException e) {
e.printStackTrace();
}
}
Aggregations