本文整理了Java中com.linecorp.armeria.common.util.Exceptions.clearTrace()
方法的一些代码示例,展示了Exceptions.clearTrace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.clearTrace()
方法的具体详情如下:
包路径:com.linecorp.armeria.common.util.Exceptions
类名称:Exceptions
方法名:clearTrace
[英]Empties the stack trace of the specified exception.
[中]清空指定异常的堆栈跟踪。
代码示例来源:origin: line/armeria
@Nonnull
private static FileServiceException newFileServiceException() {
// Remove the stack trace so we do not pollute the build log.
return Exceptions.clearTrace(new FileServiceException());
}
}
代码示例来源:origin: line/armeria
@Override
public void unaryCall(SimpleRequest request, StreamObserver<SimpleResponse> responseObserver) {
IllegalStateException e1 = new IllegalStateException("Exception 1");
IllegalArgumentException e2 = new IllegalArgumentException();
AssertionError e3 = new AssertionError("Exception 3");
Exceptions.clearTrace(e3);
RuntimeException e4 = new RuntimeException("Exception 4");
e1.initCause(e2);
e2.initCause(e3);
e3.initCause(e4);
Status status = Status.ABORTED.withCause(e1);
responseObserver.onError(status.asRuntimeException());
}
}
代码示例来源:origin: line/armeria
@Test
public void testIdentity_FileService_create_exception() throws Exception {
final FileService.Client client = new FileService.Client.Factory().getClient(inProto, outProto);
client.send_create(BAZ);
assertThat(out.length()).isGreaterThan(0);
final RuntimeException exception = Exceptions.clearTrace(new RuntimeException());
final THttpService syncService = THttpService.of((FileService.Iface) path -> {
throw exception;
}, defaultSerializationFormat);
final THttpService asyncService = THttpService.of(
(FileService.AsyncIface) (path, resultHandler) ->
resultHandler.onError(exception), defaultSerializationFormat);
invokeTwice(syncService, asyncService);
assertThat(promise.get()).isEqualTo(promise2.get());
}
代码示例来源:origin: line/armeria
@Test
public void testSync_FileService_create_exception() throws Exception {
final FileService.Client client = new FileService.Client.Factory().getClient(inProto, outProto);
client.send_create(BAZ);
assertThat(out.length()).isGreaterThan(0);
final RuntimeException exception = Exceptions.clearTrace(new RuntimeException());
final THttpService service = THttpService.of((FileService.Iface) path -> {
throw exception;
}, defaultSerializationFormat);
invoke(service);
try {
client.recv_create();
fail(TApplicationException.class.getSimpleName() + " not raised.");
} catch (TApplicationException e) {
assertThat(e.getType()).isEqualTo(TApplicationException.INTERNAL_ERROR);
assertThat(e.getMessage()).contains(exception.toString());
}
}
代码示例来源:origin: line/armeria
@Test
public void testAsync_FileService_create_exception() throws Exception {
final FileService.Client client = new FileService.Client.Factory().getClient(inProto, outProto);
client.send_create(BAZ);
assertThat(out.length()).isGreaterThan(0);
final RuntimeException exception = Exceptions.clearTrace(new RuntimeException());
final THttpService service = THttpService.of(
(FileService.AsyncIface) (path, resultHandler) ->
resultHandler.onError(exception), defaultSerializationFormat);
invoke(service);
try {
client.recv_create();
fail(TApplicationException.class.getSimpleName() + " not raised.");
} catch (TApplicationException e) {
assertThat(e.getType()).isEqualTo(TApplicationException.INTERNAL_ERROR);
assertThat(e.getMessage()).contains(exception.toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!