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

uk.nhs.ciao.io.MultiCauseIOException Maven / Gradle / Ivy

The newest version!
package uk.nhs.ciao.io;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * IOException with multiple causes.
 * 

* From Java 7 onwards: prefer {@link IOException#addSuppressed(Throwable)} */ public class MultiCauseIOException extends IOException { private static final long serialVersionUID = -8167162583826676106L; private final Exception[] causes; /** * Constructs a new exception with the specified detail message, and list of initial causes. *

* If causes contains a single exception, it is registered as the main cause (@see * {@link #getCause()}. *

* All exceptions in the causes list can be retrieved later via {@link #getCauses()} * * @param message The detail message * @param causes The list of initial causes */ public MultiCauseIOException(final String message, final List causes) { super(message); if (causes.size() == 1) { initCause(causes.get(0)); } this.causes = causes.toArray(new Exception[causes.size()]); } /** * The multiple causes associated with this exception *

* A defensive copy of the causes is returned - any modifications on the returned array * will not be reflected in subsequent calls to this method. */ public Exception[] getCauses() { // defensive copy return Arrays.copyOf(causes, causes.length); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy