com.linecorp.armeria.common.util.Exceptions.traceText()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.linecorp.armeria.common.util.Exceptions.traceText()方法的一些代码示例,展示了Exceptions.traceText()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Exceptions.traceText()方法的具体详情如下:
包路径:com.linecorp.armeria.common.util.Exceptions
类名称:Exceptions
方法名:traceText

Exceptions.traceText介绍

[英]Converts the stack trace of the specified exception into a String. This method always uses '\n' as a line delimiter, unlike Throwable#printStackTrace(PrintWriter) or Throwables#getStackTraceAsString(Throwable).
[中]将指定异常的堆栈跟踪转换为字符串。与Throwable#printStackTrace(PrintWriter)或Throwables#getStackTraceAsString(Throwable)不同,此方法始终使用“\n”作为行分隔符。

代码示例

代码示例来源:origin: line/armeria

@Test
public void maxInboundSize_tooBig() throws Exception {
  final StreamingOutputCallRequest request =
      StreamingOutputCallRequest.newBuilder()
                   .addResponseParameters(ResponseParameters.newBuilder().setSize(1))
                   .build();
  final int size = blockingStub.streamingOutputCall(request).next().getSerializedSize();
  requestLogQueue.take();
  final TestServiceBlockingStub stub =
      Clients.newDerivedClient(
          blockingStub,
          GrpcClientOptions.MAX_INBOUND_MESSAGE_SIZE_BYTES.newValue(size - 1));
  final Throwable t = catchThrowable(() -> stub.streamingOutputCall(request).next());
  assertThat(t).isInstanceOf(StatusRuntimeException.class);
  assertThat(((StatusRuntimeException) t).getStatus().getCode()).isEqualTo(Code.RESOURCE_EXHAUSTED);
  assertThat(Exceptions.traceText(t)).contains("exceeds maximum");
  checkRequestLog((rpcReq, rpcRes, grpcStatus) -> {
    assertThat(rpcReq.params()).containsExactly(request);
    assertThat(grpcStatus).isNotNull();
    assertThat(grpcStatus.getCode()).isEqualTo(Code.RESOURCE_EXHAUSTED);
  });
}

代码示例来源:origin: line/armeria

errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
                MediaType.PLAIN_TEXT_UTF_8,
                Exceptions.traceText(cause));
} else {
  errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR);

代码示例来源:origin: line/armeria

@Test
public void maxOutboundSize_tooBig() throws Exception {
  // set at least one field to ensure the size is non-zero.
  final StreamingOutputCallRequest request =
      StreamingOutputCallRequest.newBuilder()
                   .addResponseParameters(ResponseParameters.newBuilder().setSize(1))
                   .build();
  final TestServiceBlockingStub stub =
      Clients.newDerivedClient(
          blockingStub,
          GrpcClientOptions.MAX_OUTBOUND_MESSAGE_SIZE_BYTES.newValue(
              request.getSerializedSize() - 1));
  final Throwable t = catchThrowable(() -> stub.streamingOutputCall(request).next());
  assertThat(t).isInstanceOf(StatusRuntimeException.class);
  assertThat(((StatusRuntimeException) t).getStatus().getCode()).isEqualTo(Code.CANCELLED);
  assertThat(Exceptions.traceText(t)).contains("message too large");
  checkRequestLog((rpcReq, rpcRes, grpcStatus) -> {
    assertThat(rpcReq.params()).containsExactly(request);
    assertThat(grpcStatus).isNotNull();
    assertThat(grpcStatus.getCode()).isEqualTo(Code.CANCELLED);
  });
}

代码示例来源:origin: line/armeria

TApplicationException.INTERNAL_ERROR,
      "\n---- BEGIN server-side trace ----\n" +
      Exceptions.traceText(cause) +
      "---- END server-side trace ----");
} else {

代码示例来源:origin: line/armeria

errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                "Failed to decode a %s header: %s", serializationFormat,
                Exceptions.traceText(e));
} else {
  errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9-shaded

errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
                MediaType.PLAIN_TEXT_UTF_8,
                Exceptions.traceText(cause));
} else {
  errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR);

代码示例来源:origin: com.linecorp.armeria/armeria-thrift

errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
                MediaType.PLAIN_TEXT_UTF_8,
                Exceptions.traceText(cause));
} else {
  errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR);

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9

errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR,
                MediaType.PLAIN_TEXT_UTF_8,
                Exceptions.traceText(cause));
} else {
  errorRes = HttpResponse.of(HttpStatus.INTERNAL_SERVER_ERROR);

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9-shaded

TApplicationException.INTERNAL_ERROR,
      "\n---- BEGIN server-side trace ----\n" +
      Exceptions.traceText(cause) +
      "---- END server-side trace ----");
} else {

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9-shaded

errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                "Failed to decode a %s header: %s", serializationFormat,
                Exceptions.traceText(e));
} else {
  errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,

代码示例来源:origin: com.linecorp.armeria/armeria-thrift

TApplicationException.INTERNAL_ERROR,
      "\n---- BEGIN server-side trace ----\n" +
      Exceptions.traceText(cause) +
      "---- END server-side trace ----");
} else {

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9

TApplicationException.INTERNAL_ERROR,
      "\n---- BEGIN server-side trace ----\n" +
      Exceptions.traceText(cause) +
      "---- END server-side trace ----");
} else {

代码示例来源:origin: com.linecorp.armeria/armeria-thrift0.9

errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                "Failed to decode a %s header: %s", serializationFormat,
                Exceptions.traceText(e));
} else {
  errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,

代码示例来源:origin: com.linecorp.armeria/armeria-thrift

errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                "Failed to decode a %s header: %s", serializationFormat,
                Exceptions.traceText(e));
} else {
  errorRes = HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,

相关文章