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