001package org.eclipse.aether; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022/** 023 * The base class for exceptions thrown by the repository system. <em>Note:</em> Unless otherwise noted, instances of 024 * this class and its subclasses will not persist fields carrying extended error information during serialization. 025 */ 026public class RepositoryException 027 extends Exception 028{ 029 030 /** 031 * Creates a new exception with the specified detail message. 032 * 033 * @param message The detail message, may be {@code null}. 034 */ 035 public RepositoryException( String message ) 036 { 037 super( message ); 038 } 039 040 /** 041 * Creates a new exception with the specified detail message and cause. 042 * 043 * @param message The detail message, may be {@code null}. 044 * @param cause The exception that caused this one, may be {@code null}. 045 */ 046 public RepositoryException( String message, Throwable cause ) 047 { 048 super( message, cause ); 049 } 050 051 /** 052 * @param prefix The prefix. 053 * @param cause The exception that caused this one, may be {@code null}. 054 * @return The message. 055 * @noreference This method is not intended to be used by clients. 056 */ 057 protected static String getMessage( String prefix, Throwable cause ) 058 { 059 String msg = ""; 060 if ( cause != null ) 061 { 062 msg = cause.getMessage(); 063 if ( msg == null || msg.length() <= 0 ) 064 { 065 msg = cause.getClass().getSimpleName(); 066 } 067 msg = prefix + msg; 068 } 069 return msg; 070 } 071 072}