001    package org.apache.maven.model.resolution;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import org.apache.maven.model.Repository;
023    
024    /**
025     * Signals an error when adding a repository to the model resolver.
026     * 
027     * @author Benjamin Bentmann
028     */
029    public class InvalidRepositoryException
030        extends Exception
031    {
032    
033        /**
034         * The repository that raised this error, can be {@code null}.
035         */
036        private Repository repository;
037    
038        /**
039         * Creates a new exception with specified detail message and cause for the given repository.
040         * 
041         * @param message The detail message, may be {@code null}.
042         * @param repository The repository that caused the error, may be {@code null}.
043         * @param cause The cause, may be {@code null}.
044         */
045        public InvalidRepositoryException( String message, Repository repository, Throwable cause )
046        {
047            super( message, cause );
048            this.repository = repository;
049        }
050    
051        /**
052         * Creates a new exception with specified detail message for the given repository.
053         * 
054         * @param message The detail message, may be {@code null}.
055         * @param repository The repository that caused the error, may be {@code null}.
056         */
057        public InvalidRepositoryException( String message, Repository repository )
058        {
059            super( message );
060            this.repository = repository;
061        }
062    
063        /**
064         * Gets the repository that causes this error (if any).
065         * 
066         * @return The repository that causes this error or {@code null} if not known.
067         */
068        public Repository getRepository()
069        {
070            return repository;
071        }
072    
073    }