Java 类org.apache.commons.lang3.exception.ExceptionContext 实例源码

项目:java-triton    文件:CloudApiUtils.java   
/**
 * Appends context attributes for the HTTP request and HTTP response objects
 * to a {@link ExceptionContext} instance.
 *
 * @param exception exception to append to
 * @param request HTTP request object
 * @param response HTTP response object
 */
public static void annotateContextedException(final ExceptionContext exception,
                                              final HttpRequest request,
                                              final HttpResponse response) {
    Objects.requireNonNull(exception, "Exception context object must be present");

    if (request != null) {
        final Header requestIdHeader = request.getFirstHeader(CloudApiHttpHeaders.REQUEST_ID);

        if (requestIdHeader != null) {
            final String requestId = requestIdHeader.getValue();
            exception.setContextValue("requestId", requestId);
        } else {
            exception.setContextValue("requestId", "[not set]");
        }

        exception.setContextValue("request", request);
        final String requestHeaders = asString(request.getAllHeaders());
        exception.setContextValue("requestHeaders", requestHeaders);
    }

    if (response != null) {
        exception.setContextValue("response", response);
        final String responseHeaders = asString(response.getAllHeaders());
        exception.setContextValue("responseHeaders", responseHeaders);
    }
}
项目:java-triton    文件:CloudApiUtils.java   
/**
 * Appends context attributes for the HTTP request and HTTP response objects
 * to a {@link ExceptionContext} instance.
 *
 * @param exception exception to append to
 * @param request HTTP request object
 */
public static void annotateContextedException(final ExceptionContext exception,
                                              final HttpRequest request) {
    annotateContextedException(exception, request, null);
}
项目:java-triton    文件:CloudApiIOException.java   
/**
 * Adds information helpful to a developer in diagnosing and correcting the problem.
 * For the information to be meaningful, the value passed should have a reasonable
 * toString() implementation.
 * Different values can be added with the same label multiple times.
 * <p>
 * Note: This exception is only serializable if the object added is serializable.
 * </p>
 *
 * @param label  a textual label associated with information, {@code null} not recommended
 * @param value  information needed to understand exception, may be {@code null}
 * @return {@code this}, for method chaining, not {@code null}
 */
@Override
public ExceptionContext addContextValue(final String label, final Object value) {
    exceptionContext.addContextValue(label, value);
    return this;
}
项目:java-triton    文件:CloudApiIOException.java   
/**
 * Sets information helpful to a developer in diagnosing and correcting the problem.
 * For the information to be meaningful, the value passed should have a reasonable
 * toString() implementation.
 * Any existing values with the same labels are removed before the new one is added.
 * <p>
 * Note: This exception is only serializable if the object added as value is serializable.
 * </p>
 *
 * @param label  a textual label associated with information, {@code null} not recommended
 * @param value  information needed to understand exception, may be {@code null}
 * @return {@code this}, for method chaining, not {@code null}
 */
@Override
public ExceptionContext setContextValue(final String label, final Object value) {
    exceptionContext.setContextValue(label, value);
    return this;
}
项目:remote-procedure-call    文件:RpcException.java   
/**
 * Constructor
 * 
 * @param message the description of this exception
 * @param cause the cause of this exception
 * @param context a context stores the contextual information
 */
public RpcException(String message, Throwable cause, ExceptionContext context) {
    super(message, cause, context);
}
项目:remote-procedure-call    文件:ClientSideException.java   
/**
 * Constructor
 * 
 * @param message the description of this exception
 * @param cause the cause of this exception
 * @param context a context stores the contextual information
 */
public ClientSideException(String message, Throwable cause, ExceptionContext context) {
    super(message, cause, context);
}
项目:remote-procedure-call    文件:ServerSideException.java   
/**
 * Constructor
 * 
 * @param message the description of this exception
 * @param cause the cause of this exception
 * @param context a context stores the contextual information
 */
public ServerSideException(String message, Throwable cause, ExceptionContext context) {
    super(message, cause, context);
}
项目:remote-procedure-call    文件:ConfigurationException.java   
/**
 * Constructor
 * 
 * @param message the description of this exception
 * @param cause the cause of this exception
 * @param context a context stores the contextual information
 */
public ConfigurationException(String message, Throwable cause, ExceptionContext context) {
    super(message, cause, context);
}