View Javadoc
1   package org.eclipse.aether;
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  /**
23   * The base class for exceptions thrown by the repository system. <em>Note:</em> Unless otherwise noted, instances of
24   * this class and its subclasses will not persist fields carrying extended error information during serialization.
25   */
26  public class RepositoryException
27      extends Exception
28  {
29  
30      /**
31       * Creates a new exception with the specified detail message.
32       * 
33       * @param message The detail message, may be {@code null}.
34       */
35      public RepositoryException( String message )
36      {
37          super( message );
38      }
39  
40      /**
41       * Creates a new exception with the specified detail message and cause.
42       * 
43       * @param message The detail message, may be {@code null}.
44       * @param cause The exception that caused this one, may be {@code null}.
45       */
46      public RepositoryException( String message, Throwable cause )
47      {
48          super( message, cause );
49      }
50  
51      /**
52       * @param  prefix The prefix.
53       * @param cause The exception that caused this one, may be {@code null}.
54       * @return The message.
55       * @noreference This method is not intended to be used by clients.
56       */
57      protected static String getMessage( String prefix, Throwable cause )
58      {
59          String msg = "";
60          if ( cause != null )
61          {
62              msg = cause.getMessage();
63              if ( msg == null || msg.length() <= 0 )
64              {
65                  msg = cause.getClass().getSimpleName();
66              }
67              msg = prefix + msg;
68          }
69          return msg;
70      }
71  
72  }