001    /*
002     * (c) 2003-2005, 2009, 2010 ThoughtWorks Ltd
003     * All rights reserved.
004     *
005     * The software in this package is published under the terms of the BSD
006     * style license a copy of which has been included with this distribution in
007     * the LICENSE.txt file.
008     * 
009     * Created on 17-May-2004
010     */
011    package com.thoughtworks.proxy.toys.delegate;
012    
013    /**
014     * Exception thrown if a delegation from the proxy to the delegated object fails.
015     *
016     * @author Dan North
017     * @since 0.1
018     */
019    public class DelegationException extends RuntimeException {
020    
021        private static final long serialVersionUID = -8777676199121620549L;
022        private final Object delegate;
023    
024        /**
025         * Construct a DelegationException.
026         *
027         * @param message  the meaningful message.
028         * @param cause    a causing {@link Throwable}
029         * @param delegate the delegated object
030         * @since 0.1
031         */
032        public DelegationException(final String message, final Throwable cause, final Object delegate) {
033            super(message, cause);
034            this.delegate = delegate;
035        }
036    
037        /**
038         * Returns the delegated object.
039         *
040         * @return the delegated object
041         * @since 0.1
042         */
043        public Object getDelegate() {
044            return delegate;
045        }
046    }