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