1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin

File PluginException.java

 

Coverage histogram

../../../../img/srcFileCovDistChart2.png
81% of files have more coverage

Code metrics

0
15
8
1
148
55
8
0.53
1.88
8
1

Classes

Class Line # Actions
PluginException 33 15 0% 8 20
0.1304347813%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.plugin;
21   
22    import java.text.MessageFormat;
23   
24    import com.xpn.xwiki.XWikiException;
25   
26    /**
27    * XWiki-specific exceptions thrown by plugins.
28    *
29    * @version $Id: e05d2bc71f2fceff37a5a1862a2c67542f18a757 $
30    * @deprecated the plugin technology is deprecated, and XWikiException was a bad idea from the start
31    */
32    @Deprecated
 
33    public class PluginException extends XWikiException
34    {
35    /** Custom message format to use for plugin exceptions. */
36    private static final MessageFormat CUSTOM_MESSAGE = new MessageFormat("Exception in plugin [{0}]: {1}");
37   
38    /** The name of the plugin that triggered the exception. */
39    private final String pluginName;
40   
41    /**
42    * Exception constructor.
43    *
44    * @param pluginName the name of the plugin that triggered the exception
45    * @param code exception code
46    * @param message the exception message
47    * @param e a nested exception that caused this exception in the first place
48    * @param args extra information about the exception
49    */
 
50  0 toggle public PluginException(String pluginName, int code, String message, Throwable e, Object[] args)
51    {
52  0 super(XWikiException.MODULE_XWIKI_PLUGINS, code, CUSTOM_MESSAGE.format(new Object[] { pluginName, message }),
53    e, args);
54  0 this.pluginName = pluginName;
55    }
56   
57    /**
58    * Exception constructor.
59    *
60    * @param pluginName the name of the plugin that triggered the exception
61    * @param code exception code
62    * @param message the exception message
63    * @param e a nested exception that caused this exception in the first place
64    */
 
65  0 toggle public PluginException(String pluginName, int code, String message, Throwable e)
66    {
67  0 super(XWikiException.MODULE_XWIKI_PLUGINS, code, CUSTOM_MESSAGE.format(new Object[] { pluginName, message }),
68    e);
69  0 this.pluginName = pluginName;
70    }
71   
72    /**
73    * Exception constructor.
74    *
75    * @param pluginName the name of the plugin that triggered the exception
76    * @param code exception code
77    * @param message the exception message
78    */
 
79  15 toggle public PluginException(String pluginName, int code, String message)
80    {
81  15 super(XWikiException.MODULE_XWIKI_PLUGINS, code, CUSTOM_MESSAGE.format(new Object[] { pluginName, message }));
82  15 this.pluginName = pluginName;
83    }
84   
85    /**
86    * Exception constructor.
87    *
88    * @param plugin the type of plugin that triggered the exception
89    * @param code exception code
90    * @param message the exception message
91    * @param e a nested exception that caused this exception in the first place
92    * @param args extra information about the exception
93    */
 
94  0 toggle public PluginException(java.lang.Class<? extends XWikiPluginInterface> plugin, int code, String message,
95    Throwable e, Object[] args)
96    {
97  0 super(XWikiException.MODULE_XWIKI_PLUGINS, code,
98    CUSTOM_MESSAGE.format(new Object[] { plugin.getName(), message }), e, args);
99  0 this.pluginName = plugin.getName();
100    }
101   
102    /**
103    * Exception constructor.
104    *
105    * @param plugin the type of plugin that triggered the exception
106    * @param code exception code
107    * @param message the exception message
108    * @param e a nested exception that caused this exception in the first place
109    */
 
110  0 toggle public PluginException(java.lang.Class<? extends XWikiPluginInterface> plugin, int code, String message,
111    Throwable e)
112    {
113  0 super(XWikiException.MODULE_XWIKI_PLUGINS, code,
114    CUSTOM_MESSAGE.format(new Object[] { plugin.getName(), message }), e);
115  0 this.pluginName = plugin.getName();
116    }
117   
118    /**
119    * Exception constructor.
120    *
121    * @param plugin the type of plugin that triggered the exception
122    * @param code exception code
123    * @param message the exception message
124    */
 
125  0 toggle public PluginException(java.lang.Class<? extends XWikiPluginInterface> plugin, int code, String message)
126    {
127  0 super(XWikiException.MODULE_XWIKI_PLUGINS, code,
128    CUSTOM_MESSAGE.format(new Object[] { plugin.getName(), message }));
129  0 this.pluginName = plugin.getName();
130    }
131   
132    /** Empty constructor, with no information provided. */
 
133  0 toggle public PluginException()
134    {
135  0 super();
136  0 this.pluginName = "unknown";
137    }
138   
139    /**
140    * Get the name of the plugin that triggered the exception.
141    *
142    * @return the plugin name, see {@link XWikiPluginInterface#getName()}
143    */
 
144  0 toggle public String getPluginName()
145    {
146  0 return this.pluginName;
147    }
148    }