001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.util;
020
021import lucee.runtime.PageContext;
022import lucee.runtime.PageSource;
023import lucee.runtime.db.SQL;
024import lucee.runtime.exp.PageException;
025
026/**
027 * class to get exceptions of different types
028 */
029public interface Excepton {
030
031    /**
032     * Field <code>TYPE_ABORT</code>
033     */
034    public static final int TYPE_ABORT=0;
035    /**
036     * Field <code>TYPE_ABORT_EXP</code>
037     */
038    public static final int TYPE_ABORT_EXP=1;
039    /**
040     * Field <code>TYPE_APPLICATION_EXP</code>
041     */
042    public static final int TYPE_APPLICATION_EXP=2;
043    /**
044     * Field <code>TYPE_CASTER_EXP</code>
045     */
046    public static final int TYPE_CASTER_EXP=3;
047    /**
048     * Field <code>TYPE_CUSTOM_TYPE_EXP</code>
049     */
050    public static final int TYPE_CUSTOM_TYPE_EXP=4;
051    /**
052     * Field <code>TYPE_DATABASE_EXP</code>
053     */
054    public static final int TYPE_DATABASE_EXP=5;
055    /**
056     * Field <code>TYPE_EXPRESSION_EXP</code>
057     */
058    public static final int TYPE_EXPRESSION_EXP=6;
059    /**
060     * Field <code>TYPE_FUNCTION_EXP</code>
061     */
062    public static final int TYPE_FUNCTION_EXP=7;
063    /**
064     * Field <code>TYPE_LOCK_EXP</code>
065     */
066    public static final int TYPE_LOCK_EXP=8;
067    /**
068     * Field <code>TYPE_MISSING_INCLUDE_EXP</code>
069     */
070    public static final int TYPE_MISSING_INCLUDE_EXP=9;
071    /**
072     * Field <code>TYPE_NATIVE_EXP</code>
073     */
074    public static final int TYPE_NATIVE_EXP=10;
075    /**
076     * Field <code>TYPE_SECURITY_EXP</code>
077     */
078    public static final int TYPE_SECURITY_EXP=11;
079    /**
080     * Field <code>TYPE_TEMPLATE_EXP</code>
081     */
082    public static final int TYPE_TEMPLATE_EXP=12;
083    /**
084     * Field <code>TYPE_XML_EXP</code>
085     */
086    public static final int TYPE_XML_EXP=13;
087    
088    /**
089     * create exception "Abort"
090     * @return Abort
091     */
092    public PageException createAbort();
093    
094    /**
095     * create exception "AbortException"
096     * @param showError 
097     * @return AbortException
098     */
099    public PageException createAbortException(String showError);
100    
101    /**
102     * create exception "ApplicationException"
103     * @param message 
104     * @return ApplicationException
105     */
106    public PageException createApplicationException(String message);
107    
108    /**
109     * create exception "ApplicationException"
110     * @param message 
111     * @param detail 
112     * @return ApplicationException
113     */
114    public PageException createApplicationException(String message, String detail);
115    
116    /**
117     * create exception "CasterException"
118     * @param message 
119     * @return CasterException
120     */
121    public PageException createCasterException(String message);
122    
123    /**
124     * create exception "CustomTypeException"
125     * @param message 
126     * @param detail 
127     * @param errorcode 
128     * @param customType 
129     * @return CustomTypeException
130     * @deprecated use instead <code>createCustomTypeException(String message, String detail, String errorcode, String customType, String extendedInfo);</code>
131     */
132    public PageException createCustomTypeException(String message, String detail, String errorcode, String customType);
133    
134    public PageException createCustomTypeException(String message, String detail, String errorcode, String customType, String extendedInfo);
135    
136    /**
137     * create exception "DatabaseException"
138     * @param message 
139     * @return DatabaseException
140     */
141    public PageException createDatabaseException(String message);
142    
143    /**
144     * create exception "DatabaseException"
145     * @param message 
146     * @param detail 
147     * @return DatabaseException
148     */
149    public PageException createDatabaseException(String message, String detail);
150    
151    /**
152     * create exception "DatabaseException"
153     * @param message 
154     * @param sql 
155     * @return DatabaseException
156     */
157    public PageException createDatabaseException(String message, SQL sql);
158    
159    /**
160     * create exception "ExpressionException"
161     * @param message 
162     * @return ExpressionException
163     */
164    public PageException createExpressionException(String message);
165    
166    /**
167     * create exception "ExpressionException"
168     * @param message 
169     * @param detail 
170     * @return ExpressionException
171     */
172    public PageException createExpressionException(String message, String detail);
173    
174    /**
175     * create exception "FunctionException"
176     * @param pc 
177     * @param functionName 
178     * @param badArgumentPosition 
179     * @param badArgumentName 
180     * @param message 
181     * @return FunctionException
182     * @deprecated use instead <code>createFunctionException(PageContext pc,String functionName, int badArgumentPosition, String badArgumentName, String message, String detail))</code>
183     */
184    public PageException createFunctionException(PageContext pc,String functionName, String badArgumentPosition, String badArgumentName, String message);
185    
186    /**
187     * create exception "FunctionException"
188     * @param pc 
189     * @param functionName 
190     * @param badArgumentPosition 
191     * @param badArgumentName 
192     * @param message 
193     * @return FunctionException
194     */
195    public PageException createFunctionException(PageContext pc,String functionName, int badArgumentPosition, String badArgumentName, String message, String detail);
196    
197    /**
198     * create exception "LockException"
199     * @param operation 
200     * @param name 
201     * @param message 
202     * @return LockException
203     */
204    public PageException createLockException(String operation, String name, String message);
205    
206    /**
207     * create exception "LockException" 
208     * @param ps 
209     * @return LockException
210     */
211    public PageException createMissingIncludeException(PageSource ps);
212    
213    /**
214     * create exception "NativeException" 
215     * @param t 
216     * @return NativeException
217     */
218    public PageException createNativeException(Throwable t);
219    
220    /**
221     * create exception "SecurityException" 
222     * @param message 
223     * @return SecurityException
224     */
225    public PageException createSecurityException(String message);
226    
227    /**
228     * create exception "SecurityException" 
229     * @param message 
230     * @param detail 
231     * @return SecurityException
232     */
233    public PageException createSecurityException(String message, String detail);
234    
235    /**
236     * create exception "TemplateException" 
237     * @param message 
238     * @return TemplateException
239     */
240    public PageException createTemplateException(String message);
241    
242    /**
243     * create exception "TemplateException" 
244     * @param message 
245     * @param detail 
246     * @return TemplateException
247     */
248    public PageException createTemplateException(String message, String detail);
249    
250    /**
251     * create exception "XMLException" 
252     * @param message
253     * @return XMLException
254     */
255    public PageException createXMLException(String message);
256    
257    /**
258     * create exception "XMLException" 
259     * @param message 
260     * @param detail 
261     * @return XMLException
262     */
263    public PageException createXMLException(String message, String detail);
264
265    /**
266     * check if exception is of given type
267     * @param type type to check
268     * @param t exception to check
269     * @return is of type
270     */
271    public boolean isOfType(int type, Throwable t); 
272}