/** * 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); } }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }