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