1 package org.eclipse.aether.version; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import org.eclipse.aether.RepositoryException; 23 24 /** 25 * Thrown when a version or version range could not be parsed. 26 */ 27 public class InvalidVersionSpecificationException 28 extends RepositoryException 29 { 30 31 private final String version; 32 33 /** 34 * Creates a new exception with the specified version and detail message. 35 * 36 * @param version The invalid version specification, may be {@code null}. 37 * @param message The detail message, may be {@code null}. 38 */ 39 public InvalidVersionSpecificationException( String version, String message ) 40 { 41 super( message ); 42 this.version = version; 43 } 44 45 /** 46 * Creates a new exception with the specified version and cause. 47 * 48 * @param version The invalid version specification, may be {@code null}. 49 * @param cause The exception that caused this one, may be {@code null}. 50 */ 51 public InvalidVersionSpecificationException( String version, Throwable cause ) 52 { 53 super( "Could not parse version specification " + version + getMessage( ": ", cause ), cause ); 54 this.version = version; 55 } 56 57 /** 58 * Creates a new exception with the specified version, detail message and cause. 59 * 60 * @param version The invalid version specification, may be {@code null}. 61 * @param message The detail message, may be {@code null}. 62 * @param cause The exception that caused this one, may be {@code null}. 63 */ 64 public InvalidVersionSpecificationException( String version, String message, Throwable cause ) 65 { 66 super( message, cause ); 67 this.version = version; 68 } 69 70 /** 71 * Gets the version or version range that could not be parsed. 72 * 73 * @return The invalid version specification or {@code null} if unknown. 74 */ 75 public String getVersion() 76 { 77 return version; 78 } 79 80 }