|
Error handling with exceptions has several benefits to returning error codes. One of the benefits is also more information, which is provided by the exception object, comparing to simple integer error code. However, often we want to know not only exception type and error message, but also program context, when the exception occurred.
For example, IndexOutOfBounds exception should at least provide array length and the index value. Since context information which we should provide with the exception depends also on program and not only on exception type, I've implemented exception classes, which enable adding of arbitrary data. Furthermore, they format output in YAML format, so that it is human and machine readable. KException class also provides context data as key - value pairs, so recovering from exception may be easier to implement. YAML format is useful, when error information is stored to log files, and we want to search or parse that information later.
License: LGPL 2.1, contact me for commercial license at gmail, user markok3.14
Usage
There are two options. If existing exception types satisfy your needs, download the jar file and add it to your classpath. On the other hand, if you want to modify exception classes, there is so little code, that you can easily add the source code to your project and adapt it to your needs.
Customization
The KExceptions-1.0.0.jar library contains only two classes with code in method bodies. Adding of custom exception types is trivial - simply copy and rename one of derived exceptions (file name and class name in the file).
Javadoc with examples
More information can be found in javadoc API.
Downloads
KExceptions-1.0.0.jar
KExceptions-1.0.0-src.zip
KExceptions-1.0.0-doc.zip
|