Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | * $Header: /cvshome/build/org.osgi.framework/src/org/osgi/framework/BundleException.java,v 1.10 2005/05/13 20:32:55 hargrave Exp $ |
| 3 | * |
| 4 | * Copyright (c) OSGi Alliance (2000, 2005). All Rights Reserved. |
| 5 | * |
| 6 | * This program and the accompanying materials are made available under the |
| 7 | * terms of the Eclipse Public License v1.0 which accompanies this |
| 8 | * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html. |
| 9 | */ |
| 10 | |
| 11 | package org.osgi.framework; |
| 12 | |
| 13 | /** |
| 14 | * A Framework exception used to indicate that a bundle lifecycle problem |
| 15 | * occurred. |
| 16 | * |
| 17 | * <p> |
| 18 | * <code>BundleException</code> object is created by the Framework to denote an |
| 19 | * exception condition in the lifecycle of a bundle. <code>BundleException</code>s |
| 20 | * should not be created by bundle developers. |
| 21 | * |
| 22 | * <p> |
| 23 | * This exception is updated to conform to the general purpose exception |
| 24 | * chaining mechanism. |
| 25 | * |
| 26 | * @version $Revision: 1.10 $ |
| 27 | */ |
| 28 | |
| 29 | public class BundleException extends Exception { |
| 30 | static final long serialVersionUID = 3571095144220455665L; |
| 31 | /** |
| 32 | * Nested exception. |
| 33 | */ |
| 34 | private Throwable cause; |
| 35 | |
| 36 | /** |
| 37 | * Creates a <code>BundleException</code> that wraps another exception. |
| 38 | * |
| 39 | * @param msg The associated message. |
| 40 | * @param cause The cause of this exception. |
| 41 | */ |
| 42 | public BundleException(String msg, Throwable cause) { |
| 43 | super(msg); |
| 44 | this.cause = cause; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates a <code>BundleException</code> object with the specified message. |
| 49 | * |
| 50 | * @param msg The message. |
| 51 | */ |
| 52 | public BundleException(String msg) { |
| 53 | super(msg); |
| 54 | this.cause = null; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Returns any nested exceptions included in this exception. |
| 59 | * |
| 60 | * <p> |
| 61 | * This method predates the general purpose exception chaining mechanism. |
| 62 | * The {@link #getCause()} method is now the preferred means of obtaining |
| 63 | * this information. |
| 64 | * |
| 65 | * @return The nested exception; <code>null</code> if there is no nested |
| 66 | * exception. |
| 67 | */ |
| 68 | public Throwable getNestedException() { |
| 69 | return cause; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Returns the cause of this exception or <code>null</code> if no cause was |
| 74 | * specified when this exception was created. |
| 75 | * |
| 76 | * @return The cause of this exception or <code>null</code> if no cause was |
| 77 | * specified. |
| 78 | * @since 1.3 |
| 79 | */ |
| 80 | public Throwable getCause() { |
| 81 | return cause; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * The cause of this exception can only be set when constructed. |
| 86 | * |
| 87 | * @throws java.lang.IllegalStateException This method will always throw an |
| 88 | * <code>IllegalStateException</code> since the cause of this |
| 89 | * exception can only be set when constructed. |
| 90 | * @since 1.3 |
| 91 | */ |
| 92 | public Throwable initCause(Throwable cause) { |
| 93 | throw new IllegalStateException(); |
| 94 | } |
| 95 | } |