PyLucene 3.4.0-1 import
[pylucene.git] / jcc / java / org / apache / jcc / PythonException.java
1 /* ====================================================================
2  *   Licensed under the Apache License, Version 2.0 (the "License");
3  *   you may not use this file except in compliance with the License.
4  *   You may obtain a copy of the License at
5  *
6  *       http://www.apache.org/licenses/LICENSE-2.0
7  *
8  *   Unless required by applicable law or agreed to in writing, software
9  *   distributed under the License is distributed on an "AS IS" BASIS,
10  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  *   See the License for the specific language governing permissions and
12  *   limitations under the License.
13  * ====================================================================
14  */
15
16 package org.apache.jcc;
17
18
19 public class PythonException extends RuntimeException {
20     public boolean withTrace = true;
21     protected String message, errorName, traceback;
22
23     public PythonException(String message)
24     {
25         super(message);
26         getErrorInfo();  // sets errorName, message and traceback 
27     }
28
29     public String getMessage(boolean trace)
30     {
31         if (message == null)
32             message = super.getMessage();
33
34         if (trace)
35             return message + "\n" + traceback;
36
37         return message;
38     }
39
40     public String getMessage()
41     {
42         return getMessage(withTrace);
43     }
44
45     public String getErrorName()
46     {
47         return errorName;
48     }
49
50     public String getTraceback()
51     {
52         return traceback;
53     }
54
55     protected native void getErrorInfo();
56     public native void clear();
57 }