当前位置: 首页>>代码示例>>Java>>正文


Java MatrixErrorInfo类代码示例

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


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

示例1: execute

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
protected String execute(MatrixHttpRequest matrixRequest) {
    log(matrixRequest.getHttpRequest());
    try (CloseableHttpResponse response = client.execute(matrixRequest.getHttpRequest())) {

        String body = getBody(response.getEntity());
        int responseStatus = response.getStatusLine().getStatusCode();

        if (responseStatus == 200) {
            log.debug("Request successfully executed.");
        } else if (matrixRequest.getIgnoredErrorCodes().contains(responseStatus)) {
            log.debug("Error code ignored: " + responseStatus);
            return "";
        } else {
            MatrixErrorInfo info = createErrorInfo(body, responseStatus);

            body = handleError(matrixRequest, responseStatus, info);
        }
        return body;

    } catch (IOException e) {
        throw new MatrixClientRequestException(e);
    }
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:24,代码来源:AMatrixHttpClient.java

示例2: handleError

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
/**
 * Default handling of errors. Can be overwritten by a custom implementation in inherited classes.
 *
 * @param matrixRequest
 * @param responseStatus
 * @param info
 * @return body of the response of a repeated call of the request, else this methods throws a
 *         MatrixClientRequestException
 */
protected String handleError(MatrixHttpRequest matrixRequest, int responseStatus, MatrixErrorInfo info) {
    String message = String.format("Request failed with status code: %s", responseStatus);

    if (responseStatus == 429) {
        return handleRateLimited(matrixRequest, info);
    }

    throw new MatrixClientRequestException(info, message);
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:19,代码来源:AMatrixHttpClient.java

示例3: executeContentRequest

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
protected MatrixHttpContentResult executeContentRequest(MatrixHttpRequest matrixRequest) {
    log(matrixRequest.getHttpRequest());
    try (CloseableHttpResponse response = client.execute(matrixRequest.getHttpRequest())) {

        HttpEntity entity = response.getEntity();
        int responseStatus = response.getStatusLine().getStatusCode();

        MatrixHttpContentResult result = new MatrixHttpContentResult(response);

        if (responseStatus == 200) {
            log.debug("Request successfully executed.");

            if (entity == null) {
                log.debug("No data received.");
            } else if (entity.getContentType() == null) {
                log.debug("No content type was given.");
            }

        } else if (matrixRequest.getIgnoredErrorCodes().contains(responseStatus)) {
            log.debug("Error code ignored: " + responseStatus);
        } else {
            String body = getBody(entity);
            MatrixErrorInfo info = createErrorInfo(body, responseStatus);

            result = handleErrorContentRequest(matrixRequest, responseStatus, info);
        }
        return result;

    } catch (IOException e) {
        throw new MatrixClientRequestException(e);
    }
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:33,代码来源:AMatrixHttpClient.java

示例4: handleErrorContentRequest

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
protected MatrixHttpContentResult handleErrorContentRequest(MatrixHttpRequest matrixRequest, int responseStatus,
        MatrixErrorInfo info) {
    String message = String.format("Request failed with status code: %s", responseStatus);

    if (responseStatus == 429) {
        return handleRateLimitedContentRequest(matrixRequest, info);
    }

    throw new MatrixClientRequestException(info, message);
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:11,代码来源:AMatrixHttpClient.java

示例5: handleRateLimitedContentRequest

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
protected MatrixHttpContentResult handleRateLimitedContentRequest(MatrixHttpRequest matrixRequest,
        MatrixErrorInfo info) {
    throw new MatrixClientRequestException(info, "Request was rate limited.");
    // TODO Add default handling of rate limited call, i.e. repeated call after given time interval.
    // 1. Wait for timeout
    // 2. return execute(request)
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:8,代码来源:AMatrixHttpClient.java

示例6: handleBadRequest

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ExceptionHandler({InvalidMatrixIdException.class, InvalidBodyContentException.class})
@ResponseBody
MatrixErrorInfo handleBadRequest(HttpServletRequest request, MatrixException e) {
    log.error("Error when processing {} {}", request.getMethod(), request.getServletPath(), e);

    return new MatrixErrorInfo(e.getErrorCode());
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:9,代码来源:ApplicationServiceController.java

示例7: handleUnauthorized

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
@ResponseStatus(value = HttpStatus.UNAUTHORIZED)
@ExceptionHandler(NoHomeserverTokenException.class)
@ResponseBody
MatrixErrorInfo handleUnauthorized(MatrixException e) {
    return new MatrixErrorInfo(e.getErrorCode());
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:7,代码来源:ApplicationServiceController.java

示例8: handleGeneric

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Throwable.class)
@ResponseBody
MatrixErrorInfo handleGeneric(HttpServletRequest request, Throwable t) {
    log.error("Error when processing {} {}", request.getMethod(), request.getServletPath(), t);

    return new MatrixErrorInfo(t);
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:9,代码来源:ApplicationServiceController.java

示例9: createErrorInfo

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
private MatrixErrorInfo createErrorInfo(String body, int responseStatus) {
    MatrixErrorInfo info = gson.fromJson(body, MatrixErrorInfo.class);
    log.debug("Request returned with an error. Status code: {}, errcode: {}, error: {}", responseStatus,
            info.getErrcode(), info.getError());
    return info;
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:7,代码来源:AMatrixHttpClient.java

示例10: MatrixClientRequestException

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
public MatrixClientRequestException(MatrixErrorInfo errorInfo, String message) {
    super(message);

    this.errorInfo = errorInfo;
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:6,代码来源:MatrixClientRequestException.java

示例11: getError

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
public Optional<MatrixErrorInfo> getError() {
    return Optional.ofNullable(errorInfo);
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:4,代码来源:MatrixClientRequestException.java

示例12: checkErrorInfo

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
protected void checkErrorInfo(String errcode, String error, Optional<MatrixErrorInfo> errorOptional) {
    assertTrue(errorOptional.isPresent());
    assertEquals(errcode, errorOptional.get().getErrcode());
    assertEquals(error, errorOptional.get().getError());
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:6,代码来源:MatrixHttpTest.java

示例13: handleForbidden

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
@ResponseStatus(value = HttpStatus.FORBIDDEN)
@ExceptionHandler(InvalidHomeserverTokenException.class)
@ResponseBody
MatrixErrorInfo handleForbidden(MatrixException e) {
    return new MatrixErrorInfo(e.getErrorCode());
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:7,代码来源:ApplicationServiceController.java

示例14: handleNotFound

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ExceptionHandler({RoomNotFoundException.class, UserNotFoundException.class})
@ResponseBody
MatrixErrorInfo handleNotFound(MatrixException e) {
    return new MatrixErrorInfo(e.getErrorCode());
}
 
开发者ID:kamax-io,项目名称:matrix-appservice-email,代码行数:7,代码来源:ApplicationServiceController.java

示例15: handleRateLimited

import io.kamax.matrix.MatrixErrorInfo; //导入依赖的package包/类
/**
 * Default handling of rate limited calls. Can be overwritten by a custom implementation in inherited classes.
 *
 * @param matrixRequest
 * @param info
 * @return body of the response of a repeated call of the request, else this methods throws a
 *         MatrixClientRequestException
 */
protected String handleRateLimited(MatrixHttpRequest matrixRequest, MatrixErrorInfo info) {
    throw new MatrixClientRequestException(info, "Request was rate limited.");
    // TODO Add default handling of rate limited call, i.e. repeated call after given time interval.
    // 1. Wait for timeout
    // 2. return execute(request)
}
 
开发者ID:kamax-io,项目名称:matrix-java-sdk,代码行数:15,代码来源:AMatrixHttpClient.java


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