MultiThrowable (Apache Tomcat 10.1.39 API Documentation)
Description: declaration: package: org.apache.tomcat.util, class: MultiThrowable

# Class MultiThrowable

java.lang.Object
java.lang.Throwable
org.apache.tomcat.util.MultiThrowable

All Implemented Interfaces:
  `Serializable`

public class MultiThrowable extends Throwable
Wraps a list of throwables as a single throwable. This is intended to be used when multiple actions are taken where each may throw an exception but all actions are taken before any errors are reported.

This class is NOT threadsafe.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MultiThrowable()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `add(Throwable t)`
  Add a throwable to the list of wrapped throwables.
  `Throwable`
  `getThrowable()`
  `List<Throwable>`
  `getThrowables()`
  `int`
  `size()`
  `String`
  `toString()`
  Overrides the default implementation to provide a concatenation of the messages associated with each of the wrapped throwables.

  ### Methods inherited from class java.lang.Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### MultiThrowable

    public MultiThrowable()

- ## Method Details

  - ### add

    public void add(Throwable t)
    Add a throwable to the list of wrapped throwables.
    Parameters:
      `t` - The throwable to add

  - ### getThrowables

    public List<Throwable> getThrowables()
    Returns:
      A read-only list of the wrapped throwables.

  - ### getThrowable

    public Throwable getThrowable()
    Returns:
      `null` if there are no wrapped throwables, the Throwable if there is a single wrapped throwable or the current instance of there are multiple wrapped throwables

  - ### size

    public int size()
    Returns:
      The number of throwables currently wrapped by this instance.

  - ### toString

    public String toString()
    Overrides the default implementation to provide a concatenation of the messages associated with each of the wrapped throwables. Note that the format of the returned String is not guaranteed to be fixed and may change in a future release.
    Overrides:
      `toString` in class `Throwable`