• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReplyException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.vertx.core.eventbus.ReplyException的典型用法代码示例。如果您正苦于以下问题:Java ReplyException类的具体用法?Java ReplyException怎么用?Java ReplyException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReplyException类属于io.vertx.core.eventbus包,在下文中一共展示了ReplyException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: send

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
protected void send(Request request, String target) {
    DeliveryOptions options = new DeliveryOptions().setSendTimeout(request.timeout());

    core.bus().send(target, request.data(), options, send -> {
        if (send.succeeded()) {
            request.write(send.result().body());
        } else {
            Throwable exception = send.cause();

            if (exception instanceof ReplyException) {
                ReplyFailure status = ((ReplyException) exception).failureType();
                exceptionHandlers.get(status).accept(request);
            } else {
                request.error(send.cause());
            }
        }
    });
}
 
开发者ID:codingchili,项目名称:chili-core,代码行数:19,代码来源:BusRouter.java


示例2: testGetUndefinedApiEventbus

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testGetUndefinedApiEventbus(TestContext testContext) {
  Async async = testContext.async();
  JsonObject event = new JsonObject().put("name", Randoms.randomAlphabet(10)).put("namespace",
                                                                                  namespace);
  vertx.eventBus().<JsonObject>send("api.get",
      event, ar-> {
        if (ar.succeeded()) {
          testContext.fail();
        } else {
          testContext.assertTrue(ar.cause() instanceof ReplyException);
          ReplyException ex = (ReplyException) ar.cause();
          testContext.assertEquals(DefaultErrorCode.RESOURCE_NOT_FOUND.getNumber(), ex.failureCode());
          async.complete();
        }
      });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:18,代码来源:ApiDefinitionVerticleTest.java


示例3: testMissNameShouldThrowValidationException

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testMissNameShouldThrowValidationException(TestContext testContext) {
  AtomicBoolean check = new AtomicBoolean();
  vertx.eventBus().<JsonObject>send("api.delete", new JsonObject(), ar -> {
    if (ar.succeeded()) {
      testContext.fail();
    } else {
      ar.cause().printStackTrace();
      testContext.assertTrue(ar.cause() instanceof ReplyException);
      testContext.assertEquals(DefaultErrorCode.INVALID_ARGS.getNumber(),
                               ReplyException.class.cast(ar.cause()).failureCode());
      check.set(true);
    }
  });
  Awaitility.await().until(() -> check.get());

}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:18,代码来源:DeleteApiCmdTest.java


示例4: testGetApiByUndefinedNameShouldFailed

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testGetApiByUndefinedNameShouldFailed(TestContext testContext) {
  JsonObject jsonObject = new JsonObject()
          .put("namespace", namespace)
          .put("name", UUID.randomUUID().toString());
  AtomicBoolean check1 = new AtomicBoolean();

  vertx.eventBus().<JsonObject>send("api.get", jsonObject, ar -> {
    if (ar.succeeded()) {
      testContext.fail();
    } else {
      ar.cause().printStackTrace();
      testContext.assertTrue(ar.cause() instanceof ReplyException);
      testContext.assertEquals(DefaultErrorCode.RESOURCE_NOT_FOUND.getNumber(),
                               ReplyException.class.cast(ar.cause()).failureCode());
      check1.set(true);
    }
  });
  Awaitility.await().until(() -> check1.get());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:21,代码来源:GetApiCmdTest.java


示例5: testMissNameShouldThrowValidationException

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testMissNameShouldThrowValidationException(TestContext testContext) {
  AtomicBoolean check = new AtomicBoolean();
  vertx.eventBus().<JsonObject>send("api.list", new JsonObject(), ar -> {
    if (ar.succeeded()) {
      testContext.fail();
    } else {
      ar.cause().printStackTrace();
      testContext.assertTrue(ar.cause() instanceof ReplyException);
      testContext.assertEquals(DefaultErrorCode.INVALID_ARGS.getNumber(),
                               ReplyException.class.cast(ar.cause()).failureCode());
      check.set(true);
    }
  });
  Awaitility.await().until(() -> check.get());

}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:18,代码来源:ListApiCmdTest.java


示例6: replyJson

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
private static JsonObject replyJson(ReplyException ex) {
  JsonObject jsonObject = new JsonObject();
  DefaultErrorCode errorCode = DefaultErrorCode.getCode(ex.failureCode());
  if (errorCode != null) {
    jsonObject.put("code", errorCode.getNumber())
            .put("message", errorCode.getMessage());
  } else {
    ReplyFailure replyFailure = ex.failureType();
    if (replyFailure == ReplyFailure.NO_HANDLERS) {
      jsonObject.put("code", DefaultErrorCode.SERVICE_UNAVAILABLE.getNumber())
              .put("message", DefaultErrorCode.SERVICE_UNAVAILABLE.getMessage());
    } else if (replyFailure == ReplyFailure.TIMEOUT) {
      jsonObject.put("code", DefaultErrorCode.TIME_OUT.getNumber())
              .put("message", DefaultErrorCode.TIME_OUT.getMessage());
    } else if (replyFailure == ReplyFailure.RECIPIENT_FAILURE) {
      jsonObject.put("code", ex.failureCode())
              .put("message", ex.getMessage());
    } else {
      jsonObject.put("code", DefaultErrorCode.UNKOWN.getNumber())
              .put("message", DefaultErrorCode.UNKOWN.getMessage());
    }
  }
  return jsonObject;
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:25,代码来源:FailureHandler.java


示例7: failed

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
private void failed(Future<RpcResponse> completed,
                    Throwable throwable) {
  if (throwable instanceof ReplyException) {
    ReplyException ex = (ReplyException) throwable;
    if (ex.failureType() == ReplyFailure.NO_HANDLERS) {
      SystemException resourceNotFoundEx =
              SystemException.create(DefaultErrorCode.SERVICE_UNAVAILABLE)
                      .set("details", "No handlers");
      completed.fail(resourceNotFoundEx);
    } else {
      ErrorCode errorCode = CustomErrorCode.create(ex.failureCode(), ex.getMessage(), 400);
      SystemException systemException
              = SystemException.create(errorCode);
      completed.fail(systemException);
    }
  } else {
    completed.fail(throwable);
  }
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:20,代码来源:EventbusRpcHandler.java


示例8: responseAnnotations

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Override
public Collection<KeyValueAnnotation> responseAnnotations() {
  final Collection<KeyValueAnnotation> annotations = new ArrayList<>(4);

  final HttpServerResponse resp = context.response();
  annotations.add(KeyValueAnnotation.create(TraceKeys.HTTP_STATUS_CODE, String.valueOf(resp.getStatusCode())));

  if (context.failed()) {
    if (context.failure() instanceof ReplyException) {
      final ReplyException err = (ReplyException) context.failure();
      annotations.add(KeyValueAnnotation.create(VertxKeys.ReplyFailureType.getName(), err.failureType().name()));
      annotations.add(KeyValueAnnotation.create(VertxKeys.ReplyFailureCode.getName(), Integer.valueOf(err.failureCode()).toString()));
    }
    final String msg = context.failure().getMessage();
    annotations.add(KeyValueAnnotation.create(VertxKeys.ReplyFailureMessage.getName(), msg != null ? msg : ""));
  }
  return annotations;
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:19,代码来源:ZipkinWebServerResponseAdapter.java


示例9: errorResponse

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
/**
 * Generate the json error response for a failed request
 * @param throwable the cause of the error
 * @return the json string
 */
protected static String errorResponse(Throwable throwable) {
  String msg = throwableToMessage(throwable, "");

  try {
    return new JsonObject(msg).toString();
  } catch (Exception e) {
    if (throwable instanceof ReplyException) {
      return ServerAPIException.toJson(ServerAPIException.GENERIC_ERROR, msg)
        .toString();
    }

    if (throwable instanceof HttpException) {
      return ServerAPIException.toJson(ServerAPIException.HTTP_ERROR, msg)
        .toString();
    }

    return ServerAPIException.toJson(ServerAPIException.GENERIC_ERROR, msg)
      .toString();
  }
}
 
开发者ID:georocket,项目名称:georocket,代码行数:26,代码来源:AbstractEndpoint.java


示例10: delete

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Override
public void delete(String search, String path, Handler<AsyncResult<Void>> handler) {
  get(search, path, ar -> {
    if (ar.failed()) {
      Throwable cause = ar.cause();
      if (cause instanceof ReplyException) {
        // Cast to get access to the failure code
        ReplyException ex = (ReplyException)cause;

        if (ex.failureCode() == 404) {
          handler.handle(Future.succeededFuture());
          return;
        }
      }
      handler.handle(Future.failedFuture(ar.cause()));
    } else {
      StoreCursor cursor = ar.result();
      Queue<String> paths = new ArrayDeque<>();
      AtomicLong remaining = new AtomicLong(cursor.getInfo().getTotalHits());
      doDelete(cursor, paths, remaining, handler);
    }
  });
}
 
开发者ID:georocket,项目名称:georocket,代码行数:24,代码来源:IndexedStore.java


示例11: register

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
/**
 * Register the proxy handle on the event bus.
 *
 * @param eventBus the event bus
 * @param address the proxy address
 */
public MessageConsumer<JsonObject> register(EventBus eventBus, String address, List<Function<Message<JsonObject>, Future<Message<JsonObject>>>> interceptors) {
  Handler<Message<JsonObject>> handler = this::handle;
  if (interceptors != null) {
    for (Function<Message<JsonObject>, Future<Message<JsonObject>>> interceptor : interceptors) {
      Handler<Message<JsonObject>> prev = handler;
      handler = msg -> {
        Future<Message<JsonObject>> fut = interceptor.apply(msg);
        fut.setHandler(ar -> {
          if (ar.succeeded()) {
            prev.handle(msg);
          } else {
            ReplyException exception = (ReplyException) ar.cause();
            msg.fail(exception.failureCode(), exception.getMessage());
          }
        });
      };
    }
  }
  consumer = eventBus.consumer(address, handler);
  return consumer;
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:28,代码来源:ProxyHandler.java


示例12: testWithoutToken

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testWithoutToken() {

  serviceProxyBuilder
    .setToken(null);

  proxy = serviceProxyBuilder.build(OKService.class);

  proxy.ok(res -> {
    assertTrue(res.failed());
    ReplyException t = (ReplyException) res.cause();
    assertEquals(401, t.failureCode());
    testComplete();
  });
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:17,代码来源:SecureServiceBinderTest.java


示例13: testCallWithMessageParamWrongType

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testCallWithMessageParamWrongType() {
  JsonObject message = new JsonObject();
  message.put("object", new JsonObject().put("foo", "bar"));
  message.put("str", 76523);
  message.put("i", 1234);
  message.put("char", (int)'X'); // chars are mapped to ints
  message.put("enum", SomeEnum.BAR.toString()); // enums are mapped to strings
  vertx.eventBus().send("someaddress", message, new DeliveryOptions().addHeader("action", "invokeWithMessage").setSendTimeout(500), onFailure(t -> {
    assertTrue(t instanceof ReplyException);
    ReplyException re = (ReplyException) t;
    // This will as operation will fail to be invoked
    assertEquals(ReplyFailure.RECIPIENT_FAILURE, re.failureType());
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-service-proxy,代码行数:18,代码来源:ServiceProxyTest.java


示例14: sendErrFrame

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
public static void sendErrFrame(String address, String replyAddress, ReplyException failure, WriteStream<Buffer> handler) {
  final JsonObject payload = new JsonObject()
      .put("type", "err")
      .put("address", replyAddress)
      .put("sourceAddress", address)
      .put("failureCode", failure.failureCode())
      .put("failureType", failure.failureType().name())
      .put("message", failure.getMessage());

  writeFrame(payload, handler);
}
 
开发者ID:zzqfsy,项目名称:spring-vertx-tcp,代码行数:12,代码来源:FrameHelper.java


示例15: shutdownHandler

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
/**
 *  Use to terminate the application using a HTTP Post
 *  It requires an AdminKey header to work
 */
private void shutdownHandler(final RoutingContext ctx) {
	// check for AdminKey header
	String adminKey = this.config().getString("AdminKey");
	if (adminKey == null || adminKey.equals(ctx.request().getHeader("AdminKey"))) {
		// TODO: check the body for the right credentials
		this.shutdownExecution(ctx.response());
	} else {
		ctx.fail(new ReplyException(ReplyFailure.RECIPIENT_FAILURE, 401, "Sucker nice try!"));
	}
}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:15,代码来源:ApplicationStarter.java


示例16: forwardErrorCode

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
private void forwardErrorCode(RoutingContext routingContext, AsyncResult<Message<Object>> reply) {
    ReplyException ex = (ReplyException) reply.cause();
    ex.printStackTrace();
    HttpServerResponse response = routingContext.response();
    response.setStatusCode(ex.failureCode());
    response.end();
}
 
开发者ID:ftrossbach,项目名称:kiqr,代码行数:8,代码来源:RestKiqrServerVerticle.java


示例17: testMissNameShouldThrowValidationException

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Test
public void testMissNameShouldThrowValidationException(TestContext testContext) {
  AtomicBoolean check = new AtomicBoolean();
  vertx.eventBus().<JsonObject>send("api.get", new JsonObject(), ar -> {
    if (ar.succeeded()) {
      testContext.fail();
    } else {
      testContext.assertTrue(ar.cause() instanceof ReplyException);
      testContext.assertEquals(DefaultErrorCode.INVALID_ARGS.getNumber(),
                               ReplyException.class.cast(ar.cause()).failureCode());
      check.set(true);
    }
  });
  Awaitility.await().until(() -> check.get());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:16,代码来源:GetApiCmdTest.java


示例18: createServer

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Before
public void createServer(TestContext testContext) {
  vertx = Vertx.vertx();
  Router router = Router.router(vertx);
  router.route().handler(BodyHandler.create());
  router.route().handler(BaseHandler.create());
  router.get("/ex/sys").handler(rc -> {
    throw SystemException.create(DefaultErrorCode.MISSING_ARGS);
  });
  router.get("/ex/validate").handler(rc -> {
    Multimap<String, String> error = ArrayListMultimap.create();
    throw new ValidationException(error);
  });
  router.get("/ex/unkown").handler(rc -> {
    throw new RuntimeException("xxxx");
  });
  router.get("/ex/reply").handler(rc -> {
    throw new ReplyException(ReplyFailure.TIMEOUT, DefaultErrorCode.INVALID_REQ.getNumber(),
                             DefaultErrorCode.INVALID_REQ.getMessage());
  });

  router.get("/ex/reply2").handler(rc -> {
    throw new ReplyException(ReplyFailure.RECIPIENT_FAILURE);
  });
  router.route().failureHandler(FailureHandler.create());
  vertx.createHttpServer().requestHandler(router::accept)
          .listen(port, testContext.asyncAssertSuccess());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:29,代码来源:FailureHandlerTest.java


示例19: manageError

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
private static void manageError( ReplyException cause, HttpServerResponse response) {
    if(isExistingHttStatusCode(cause.failureCode())) {
        response.setStatusCode(cause.failureCode());
        if(StringUtils.isNotEmpty(cause.getMessage())) {
            response.setStatusMessage(cause.getMessage());
        }
    } else {
        response.setStatusCode(HttpResponseStatus.INTERNAL_SERVER_ERROR.code());
    }
    response.end();
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:12,代码来源:SwaggerRouter.java


示例20: responseAnnotations

import io.vertx.core.eventbus.ReplyException; //导入依赖的package包/类
@Override
public Collection<KeyValueAnnotation> responseAnnotations() {
  if (msg.body() instanceof ReplyException) {
    final ReplyException err = (ReplyException) msg.body();
    return Arrays.asList(
        KeyValueAnnotation.create(VertxKeys.ReplyFailureType.getName(), err.failureType().name()),
        KeyValueAnnotation.create(VertxKeys.ReplyFailureCode.getName(), Integer.valueOf(err.failureCode()).toString()),
        KeyValueAnnotation.create(VertxKeys.ReplyFailureMessage.getName(), err.getMessage() != null ? err.getMessage() : ""));
  } else {
    return Collections.emptyList();
  }
}
 
开发者ID:emmanuelidi,项目名称:vertx-zipkin,代码行数:13,代码来源:ZipkinEventBusServerResponseAdapter.java



注:本文中的io.vertx.core.eventbus.ReplyException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICommonMenuConstants类代码示例发布时间:2022-05-21
下一篇:
Java Timed类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap