本文整理汇总了Java中io.vertx.core.eventbus.ReplyFailure.NO_HANDLERS属性的典型用法代码示例。如果您正苦于以下问题:Java ReplyFailure.NO_HANDLERS属性的具体用法?Java ReplyFailure.NO_HANDLERS怎么用?Java ReplyFailure.NO_HANDLERS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.vertx.core.eventbus.ReplyFailure
的用法示例。
在下文中一共展示了ReplyFailure.NO_HANDLERS属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replyJson
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;
}
示例2: failed
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);
}
}
示例3: testThrowableToCodeReplyException
/**
* Test code of {@link ReplyException}
*/
@Test
public void testThrowableToCodeReplyException() {
int expectedCode = 505;
Throwable throwable = new ReplyException(ReplyFailure.NO_HANDLERS, expectedCode, "Message");
int statusCode = ThrowableHelper.throwableToCode(throwable);
assertEquals(expectedCode, statusCode);
}