All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pepsoft.util.mdc.MDCCapturingRuntimeException Maven / Gradle / Ivy

There is a newer version: 2.15.18
Show newest version
package org.pepsoft.util.mdc;

import org.slf4j.MDC;

import java.util.Map;

/**
 * A {@link RuntimeException} which captures the current contents of the {@link MDC} thread local diagnostic context at
 * the moment of throwing. The captured context is available from the {@link #getMdcContext()} method.
 *
 * 

This exception is meant for adding semantic information to the exception chain. To just capture the MDC * context, use {@link MDCWrappingRuntimeException}. */ public class MDCCapturingRuntimeException extends RuntimeException implements MDCContextProvider { public MDCCapturingRuntimeException(String message) { super(message); mdcContext = MDC.getCopyOfContextMap(); } public MDCCapturingRuntimeException(String message, Throwable cause) { super(message, cause); mdcContext = MDC.getCopyOfContextMap(); } // MDCContextProvider public final Map getMdcContext() { return mdcContext; } private final Map mdcContext; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy