001    /*****************************************************************************
002     * Copyright (C) PicoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the LICENSE.txt file.                                                     *
007     *                                                                           *
008     * Original code by                                                          *
009     *****************************************************************************/
010    package org.picocontainer;
011    
012    import java.util.ArrayList;
013    import java.util.List;
014    
015    
016    /**
017     * Subclass of {@link PicoException} that is thrown when a {@link PicoContainer} hierarchy
018     * cannot be verified. A failing verification is caused by ambuigities or missing dependencies
019     * between the registered components and their parameters. This exception is designed as a
020     * collector for all Exceptions occurring at the verification of the complete container
021     * hierarchy. The verification is normally done with the
022     * {@link org.picocontainer.visitors.VerifyingVisitor}, that will throw this exception.
023     */
024    @SuppressWarnings("serial")
025    public class PicoVerificationException extends PicoException {
026            
027            /**
028         * The exceptions that caused this one.
029         */
030        private final List<Throwable> nestedExceptions = new ArrayList<Throwable>();
031    
032        /**
033         * Construct a new exception with a list of exceptions that caused this one.
034         * 
035         * @param nestedExceptions the exceptions that caused this one.
036         */
037        public PicoVerificationException(final List<? extends Throwable> nestedExceptions) {
038            this.nestedExceptions.addAll(nestedExceptions);
039        }
040    
041        /**
042         * Retrieve the list of exceptions that caused this one.
043         * 
044         * @return the list of exceptions that caused this one.
045         */
046        public List<Throwable> getNestedExceptions() {
047            return nestedExceptions;
048        }
049    
050        /**
051         * Return a string listing of all the messages associated with the exceptions that caused
052         * this one.
053         * 
054         * @return a string listing of all the messages associated with the exceptions that caused
055         *               this one.
056         */
057        public String getMessage() {
058            return nestedExceptions.toString();
059        }
060    }