1 /******************************************************************************* 2 * Copyright (c) 2010, 2014 Sonatype, Inc. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * Sonatype, Inc. - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.aether.version; 12 13 import org.eclipse.aether.RepositoryException; 14 15 /** 16 * Thrown when a version or version range could not be parsed. 17 */ 18 public class InvalidVersionSpecificationException 19 extends RepositoryException 20 { 21 22 private final String version; 23 24 /** 25 * Creates a new exception with the specified version and detail message. 26 * 27 * @param version The invalid version specification, may be {@code null}. 28 * @param message The detail message, may be {@code null}. 29 */ 30 public InvalidVersionSpecificationException( String version, String message ) 31 { 32 super( message ); 33 this.version = version; 34 } 35 36 /** 37 * Creates a new exception with the specified version and cause. 38 * 39 * @param version The invalid version specification, may be {@code null}. 40 * @param cause The exception that caused this one, may be {@code null}. 41 */ 42 public InvalidVersionSpecificationException( String version, Throwable cause ) 43 { 44 super( "Could not parse version specification " + version + getMessage( ": ", cause ), cause ); 45 this.version = version; 46 } 47 48 /** 49 * Creates a new exception with the specified version, detail message and cause. 50 * 51 * @param version The invalid version specification, may be {@code null}. 52 * @param message The detail message, may be {@code null}. 53 * @param cause The exception that caused this one, may be {@code null}. 54 */ 55 public InvalidVersionSpecificationException( String version, String message, Throwable cause ) 56 { 57 super( message, cause ); 58 this.version = version; 59 } 60 61 /** 62 * Gets the version or version range that could not be parsed. 63 * 64 * @return The invalid version specification or {@code null} if unknown. 65 */ 66 public String getVersion() 67 { 68 return version; 69 } 70 71 }