001package org.eclipse.aether.version;
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
022import org.eclipse.aether.RepositoryException;
023
024/**
025 * Thrown when a version or version range could not be parsed.
026 */
027public class InvalidVersionSpecificationException
028    extends RepositoryException
029{
030
031    private final String version;
032
033    /**
034     * Creates a new exception with the specified version and detail message.
035     * 
036     * @param version The invalid version specification, may be {@code null}.
037     * @param message The detail message, may be {@code null}.
038     */
039    public InvalidVersionSpecificationException( String version, String message )
040    {
041        super( message );
042        this.version = version;
043    }
044
045    /**
046     * Creates a new exception with the specified version and cause.
047     * 
048     * @param version The invalid version specification, may be {@code null}.
049     * @param cause The exception that caused this one, may be {@code null}.
050     */
051    public InvalidVersionSpecificationException( String version, Throwable cause )
052    {
053        super( "Could not parse version specification " + version + getMessage( ": ", cause ), cause );
054        this.version = version;
055    }
056
057    /**
058     * Creates a new exception with the specified version, detail message and cause.
059     * 
060     * @param version The invalid version specification, may be {@code null}.
061     * @param message The detail message, may be {@code null}.
062     * @param cause The exception that caused this one, may be {@code null}.
063     */
064    public InvalidVersionSpecificationException( String version, String message, Throwable cause )
065    {
066        super( message, cause );
067        this.version = version;
068    }
069
070    /**
071     * Gets the version or version range that could not be parsed.
072     * 
073     * @return The invalid version specification or {@code null} if unknown.
074     */
075    public String getVersion()
076    {
077        return version;
078    }
079
080}