Example usage for org.apache.commons.math3.exception.util ExceptionContextProvider getContext

List of usage examples for org.apache.commons.math3.exception.util ExceptionContextProvider getContext

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception.util ExceptionContextProvider getContext.

Prototype

ExceptionContext getContext();

Source Link

Document

Gets a reference to the "rich context" data structure that allows to customize error messages and store key, value pairs in exceptions.

Usage

From source file:org.orekit.errors.OrekitException.java

/** Simple constructor.
 * Build an exception from an Apache Commons Math exception context context
 * @param provider underlying exception context provider
 * @since 6.0/*from   w  w  w  .j  a  v a  2  s. c  o  m*/
 */
public OrekitException(final ExceptionContextProvider provider) {
    super(provider.getContext().getThrowable());
    this.context = provider.getContext();
    this.specifier = null;
    this.parts = new Object[0];
}

From source file:org.orekit.errors.PropagationException.java

/** Recover a PropagationException, possibly embedded in an {@link ExceptionContextProvider}.
 * <p>// ww  w .  j a  v  a  2  s.c o m
 * If the {@code ExceptionContextProvider} does not embed a PropagationException, a
 * new one will be created.
 * </p>
 * @param provider ExceptionContextProvider to analyze
 * @return a (possibly embedded) PropagationException
 */
public static PropagationException unwrap(final ExceptionContextProvider provider) {

    for (Throwable t = provider.getContext().getThrowable(); t != null; t = t.getCause()) {
        if (t instanceof OrekitException) {
            if (t instanceof PropagationException) {
                return (PropagationException) t;
            } else {
                return new PropagationException((OrekitException) t);
            }
        }
    }

    return new PropagationException(provider);

}

From source file:org.orekit.errors.TimeStampedCacheException.java

/** Recover a PropagationException, possibly embedded in an {@link ExceptionContextProvider}.
 * <p>//  w  w  w.  j  av  a  2s. c o  m
 * If the {@code ExceptionContextProvider} does not embed a PropagationException, a
 * new one will be created.
 * </p>
 * @param provider ExceptionContextProvider to analyze
 * @return a (possibly embedded) PropagationException
 */
public static TimeStampedCacheException unwrap(final ExceptionContextProvider provider) {

    for (Throwable t = provider.getContext().getThrowable(); t != null; t = t.getCause()) {
        if (t instanceof OrekitException) {
            if (t instanceof TimeStampedCacheException) {
                return (TimeStampedCacheException) t;
            } else {
                return new TimeStampedCacheException((OrekitException) t);
            }
        }
    }

    return new TimeStampedCacheException(provider);

}

From source file:org.osk.errors.OskException.java

/** Simple constructor.
 * Build an exception from an Apache Commons Math exception context context
 * @param provider underlying exception context provider
 * @since 6.0/*from  w  ww.j  ava2 s .co m*/
 */
public OskException(final ExceptionContextProvider provider) {
    super(provider.getContext().getThrowable());
    this.context = provider.getContext();
    this.specifier = null;
    this.parts = new Object[0];
}