1 /*
2 * Copyright (c) 2003-2008 by Cosylab d. d.
3 *
4 * This file is part of CosyBeans.
5 *
6 * CosyBeans is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CosyBeans is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CosyBeans. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package com.cosylab.application;
21
22 import com.cosylab.util.CommonException;
23
24 /**
25 * An exception describing the problem with plugin installation.
26 * These checked exceptions are thrown when the construction or
27 * initialization of the plugin fail; when there are cyclic references
28 * in the plugin installation; or when the plugin does not conform
29 * to the plugin design contract.
30 */
31 public class PlugInException extends CommonException {
32
33 private static final long serialVersionUID = 1L;
34 private Class plugType = null;
35
36 /**
37 * Creates a new instance of this exception.
38 *
39 * @param source the object throwing the exception
40 * @param message message to be printed by this exception
41 * @param plugType class object representing the plug the installation of
42 * which failed (can be <code>null</code>
43 * @param t exception that caused this exception to be thrown
44 * (can be <code>null</code>)
45 */
46 public PlugInException(Object source, String message, Class plugType, Throwable t)
47 {
48 super(source, message, t);
49 this.plugType = plugType;
50 }
51
52 /**
53 * Returns a string rendering of this exception.
54 *
55 * @return String overloaded <code>toString</code> return value.
56 */
57 public String toString()
58 {
59 String plugTypeName = "N/A";
60 if (plugType != null) plugTypeName = plugType.getName();
61 String tMessage = "";
62 return getMessage() + "\nPlug type: " + plugTypeName + "\n" + "Caused by:\n" + tMessage;
63 }
64 }
65