View Javadoc
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      /** The invalid version or version range string. */
29      private final String version;
30  
31      /**
32       * Creates a new exception with the specified version and detail message.
33       *
34       * @param version The invalid version specification, may be {@code null}.
35       * @param message The detail message, may be {@code null}.
36       */
37      public InvalidVersionSpecificationException(String version, String message) {
38          super(message);
39          this.version = version;
40      }
41  
42      /**
43       * Creates a new exception with the specified version and cause.
44       *
45       * @param version The invalid version specification, may be {@code null}.
46       * @param cause The exception that caused this one, may be {@code null}.
47       */
48      public InvalidVersionSpecificationException(String version, Throwable cause) {
49          super("Could not parse version specification " + version + getMessage(": ", cause), cause);
50          this.version = version;
51      }
52  
53      /**
54       * Creates a new exception with the specified version, detail message and cause.
55       *
56       * @param version The invalid version specification, may be {@code null}.
57       * @param message The detail message, may be {@code null}.
58       * @param cause The exception that caused this one, may be {@code null}.
59       */
60      public InvalidVersionSpecificationException(String version, String message, Throwable cause) {
61          super(message, cause);
62          this.version = version;
63      }
64  
65      /**
66       * Gets the version or version range that could not be parsed.
67       *
68       * @return The invalid version specification or {@code null} if unknown.
69       */
70      public String getVersion() {
71          return version;
72      }
73  }