jk_exceptionhelper


Namejk_exceptionhelper JSON
Version 0.2024.1.3 PyPI version JSON
download
home_pageNone
SummaryAs the python exception API is quite a bit obscure this python module wraps around python exceptions to provide a clean interface for analysis and logging purposes.
upload_time2024-01-03 11:25:58
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords exception handling debugging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            jk_exceptionhelper
==================

Introduction
------------

This python module wraps around python exceptions. As the python exception API is quite a bit obscure this python module provides a clean API for analysis and logging purposes.

Information about this module can be found here:

* [github.org](https://github.com/jkpubsrc/....)
* [pypi.python.org](https://pypi.python.org/pypi/jk_exceptionhelper)

Why this module?
----------------

As the python exception API is quite a bit obscure this python module tries to solve this problem. By focusing on this problem in an isolated way improvements can easily be made without breaking and adapting a variety of implementations.

How to use this module
----------------------

### Import this module

Please include this module into your application using the following code:

```python
import jk_exceptionhelper
```

### Analyse the exeption

Example:

```python
try:
	a = 0
	b = 5 / a
except Exception as ex:
	ee = jk_exceptionhelper.analyseException(ex)
```

Now `ee` contains an instance of `ExceptionObject`. `ExceptionObject` contains all relevant information from the exception for your convenience to work with. (For details about the `ExceptionObject` API see below.)

### Output the exception data

Example:

```python
try:
	a = 0
	b = 5 / a
except Exception as ex:
	jk_exceptionhelper.analyseException(ex).dump()
```

This will print all data collected to STDOUT. Example:

```
ZeroDivisionError
: exceptionTextHR:
:	division by zero
: stackTrace:
:	(<stdin>:3, '')
\-
```

API: Functions
--------------

### Function `analyseException()`

`ExceptionObject analyseException()`

This function should be called at the first statement within an `except` block. It returns an object of type `ExceptionObject` containing all relevant information from the exception for your convenience to work with.

API: Classes
------------

## Class 'ExceptionObject'

### Fields

| Type	| Name	| Required?	| Description	|
| ----- | ----- | --------- | ------------- |
| `class`				| `exceptionClass`		| optional	| The original exception class. This instance will only be present if `analyseException()` was called within an `except` block.	|
| `str`					| `exceptionClassName`	| required	| The class name of the exception.														|
| `str`					| `exceptionTextHR`		| optional	| A human readable text that was contained within the exception.						|
| `StackTraceItem[]`	| `stackTrace`			| optional	| The stack trace. The last item of the list is the topmost stack element.				|
| `ExceptionObject`		| `nestedException`		| optional	| The parent exception object if this exception has been caught in an `except` block.	|

### Static Methods

#### Static Method `StackTraceItem fromJSON(dict data)`

`StackTraceItem fromJSON(dict data)`

Deserialize a data structure created by `toJSON()`.

### Methods

#### Method `void dump()`

`void dump()`

Print the contents of the exception to STDOUT.

Example:

```python
try:
	a = 0
	b = 5 / a
except:
	analyseException().dump()
```

This will print something like this:

```
ZeroDivisionError
: exceptionTextHR:
:	division by zero
: stackTrace:
:	(./test2.py:55, 'b = 5 / a')
:	(./test2.py:59, 'main3()')
:	(./test2.py:63, 'main2()')
:	(./test2.py:67, 'main1()')
```

#### Method `dict toJSON(bool bRecursive = True)`

`dict toJSON(bool bRecursive = True)`

Serialize the exception object to JSON format.

Arguments:

* `bool bRecursive` : If `True` (which is the default) nested exceptions are serialized as well. If `False` these get skipped.

Example:

```python
try:
	a = 0
	b = 5 / a
except:
	edata = analyseException().toJSON()
```

#### Method `dict toJSON(bool bRecursive = True)`

`dict toJSON_flat()`

Same as `toJSON(False)`.

Arguments:

* (none)

Contact Information
-------------------

This is Open Source code. That not only gives you the possibility of freely using this code it also
allows you to contribute. Feel free to contact the author(s) of this software listed below, either
for comments, collaboration requests, suggestions for improvement or reporting bugs:

* Jürgen Knauth: jknauth@uni-goettingen.de, pubsrc@binary-overflow.de

License
-------

This software is provided under the following license:

* Apache Software License 2.0




            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "jk_exceptionhelper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "J\u00fcrgen Knauth <pubsrc@binary-overflow.de>",
    "keywords": "exception handling,debugging",
    "author": null,
    "author_email": "J\u00fcrgen Knauth <pubsrc@binary-overflow.de>",
    "download_url": "https://files.pythonhosted.org/packages/34/26/23e0ad92f66c2020e4cd7700f9a471062b8504e7b5473cf147311150c699/jk_exceptionhelper-0.2024.1.3.tar.gz",
    "platform": null,
    "description": "jk_exceptionhelper\n==================\n\nIntroduction\n------------\n\nThis python module wraps around python exceptions. As the python exception API is quite a bit obscure this python module provides a clean API for analysis and logging purposes.\n\nInformation about this module can be found here:\n\n* [github.org](https://github.com/jkpubsrc/....)\n* [pypi.python.org](https://pypi.python.org/pypi/jk_exceptionhelper)\n\nWhy this module?\n----------------\n\nAs the python exception API is quite a bit obscure this python module tries to solve this problem. By focusing on this problem in an isolated way improvements can easily be made without breaking and adapting a variety of implementations.\n\nHow to use this module\n----------------------\n\n### Import this module\n\nPlease include this module into your application using the following code:\n\n```python\nimport jk_exceptionhelper\n```\n\n### Analyse the exeption\n\nExample:\n\n```python\ntry:\n\ta = 0\n\tb = 5 / a\nexcept Exception as ex:\n\tee = jk_exceptionhelper.analyseException(ex)\n```\n\nNow `ee` contains an instance of `ExceptionObject`. `ExceptionObject` contains all relevant information from the exception for your convenience to work with. (For details about the `ExceptionObject` API see below.)\n\n### Output the exception data\n\nExample:\n\n```python\ntry:\n\ta = 0\n\tb = 5 / a\nexcept Exception as ex:\n\tjk_exceptionhelper.analyseException(ex).dump()\n```\n\nThis will print all data collected to STDOUT. Example:\n\n```\nZeroDivisionError\n: exceptionTextHR:\n:\tdivision by zero\n: stackTrace:\n:\t(<stdin>:3, '')\n\\-\n```\n\nAPI: Functions\n--------------\n\n### Function `analyseException()`\n\n`ExceptionObject analyseException()`\n\nThis function should be called at the first statement within an `except` block. It returns an object of type `ExceptionObject` containing all relevant information from the exception for your convenience to work with.\n\nAPI: Classes\n------------\n\n## Class 'ExceptionObject'\n\n### Fields\n\n| Type\t| Name\t| Required?\t| Description\t|\n| ----- | ----- | --------- | ------------- |\n| `class`\t\t\t\t| `exceptionClass`\t\t| optional\t| The original exception class. This instance will only be present if `analyseException()` was called within an `except` block.\t|\n| `str`\t\t\t\t\t| `exceptionClassName`\t| required\t| The class name of the exception.\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n| `str`\t\t\t\t\t| `exceptionTextHR`\t\t| optional\t| A human readable text that was contained within the exception.\t\t\t\t\t\t|\n| `StackTraceItem[]`\t| `stackTrace`\t\t\t| optional\t| The stack trace. The last item of the list is the topmost stack element.\t\t\t\t|\n| `ExceptionObject`\t\t| `nestedException`\t\t| optional\t| The parent exception object if this exception has been caught in an `except` block.\t|\n\n### Static Methods\n\n#### Static Method `StackTraceItem fromJSON(dict data)`\n\n`StackTraceItem fromJSON(dict data)`\n\nDeserialize a data structure created by `toJSON()`.\n\n### Methods\n\n#### Method `void dump()`\n\n`void dump()`\n\nPrint the contents of the exception to STDOUT.\n\nExample:\n\n```python\ntry:\n\ta = 0\n\tb = 5 / a\nexcept:\n\tanalyseException().dump()\n```\n\nThis will print something like this:\n\n```\nZeroDivisionError\n: exceptionTextHR:\n:\tdivision by zero\n: stackTrace:\n:\t(./test2.py:55, 'b = 5 / a')\n:\t(./test2.py:59, 'main3()')\n:\t(./test2.py:63, 'main2()')\n:\t(./test2.py:67, 'main1()')\n```\n\n#### Method `dict toJSON(bool bRecursive = True)`\n\n`dict toJSON(bool bRecursive = True)`\n\nSerialize the exception object to JSON format.\n\nArguments:\n\n* `bool bRecursive` : If `True` (which is the default) nested exceptions are serialized as well. If `False` these get skipped.\n\nExample:\n\n```python\ntry:\n\ta = 0\n\tb = 5 / a\nexcept:\n\tedata = analyseException().toJSON()\n```\n\n#### Method `dict toJSON(bool bRecursive = True)`\n\n`dict toJSON_flat()`\n\nSame as `toJSON(False)`.\n\nArguments:\n\n* (none)\n\nContact Information\n-------------------\n\nThis is Open Source code. That not only gives you the possibility of freely using this code it also\nallows you to contribute. Feel free to contact the author(s) of this software listed below, either\nfor comments, collaboration requests, suggestions for improvement or reporting bugs:\n\n* J\u00fcrgen Knauth: jknauth@uni-goettingen.de, pubsrc@binary-overflow.de\n\nLicense\n-------\n\nThis software is provided under the following license:\n\n* Apache Software License 2.0\n\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "As the python exception API is quite a bit obscure this python module wraps around python exceptions to provide a clean interface for analysis and logging purposes.",
    "version": "0.2024.1.3",
    "project_urls": null,
    "split_keywords": [
        "exception handling",
        "debugging"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "847481aa8f3b9f3cf1caf8e5fcaa725d9397563b9c6d947cecf2c5f5077a835a",
                "md5": "0dd053ec930bf91253165c38af165536",
                "sha256": "95a8ade21d6eae9a66a3830511b9e511ced51a2b39a6332e81ef43400249bdd1"
            },
            "downloads": -1,
            "filename": "jk_exceptionhelper-0.2024.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0dd053ec930bf91253165c38af165536",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7502,
            "upload_time": "2024-01-03T11:25:57",
            "upload_time_iso_8601": "2024-01-03T11:25:57.026998Z",
            "url": "https://files.pythonhosted.org/packages/84/74/81aa8f3b9f3cf1caf8e5fcaa725d9397563b9c6d947cecf2c5f5077a835a/jk_exceptionhelper-0.2024.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "342623e0ad92f66c2020e4cd7700f9a471062b8504e7b5473cf147311150c699",
                "md5": "29357b5851a53cbc31273555a22e9365",
                "sha256": "4c507cab6cdc3b4d6a0b5fc5d7bc83dc99c7183cd3dda83092a5a822ab946474"
            },
            "downloads": -1,
            "filename": "jk_exceptionhelper-0.2024.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "29357b5851a53cbc31273555a22e9365",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7039,
            "upload_time": "2024-01-03T11:25:58",
            "upload_time_iso_8601": "2024-01-03T11:25:58.971606Z",
            "url": "https://files.pythonhosted.org/packages/34/26/23e0ad92f66c2020e4cd7700f9a471062b8504e7b5473cf147311150c699/jk_exceptionhelper-0.2024.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 11:25:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "jk_exceptionhelper"
}
        
Elapsed time: 0.16361s