kr
Utils to work with json
To install: pip install kr
Overview
The kr package provides utility functions to handle JSON data, specifically focusing on error handling and reporting. It includes functions to convert error objects into dictionary or JSON format, optionally including traceback information to aid in debugging.
Features
- Error Object Serialization: Convert exceptions and errors into a more readable and structured JSON format.
- Traceback Inclusion: Option to include traceback details in the serialized error output, which can be very helpful for debugging.
Functions
get_dict_of_error_object(error_object, with_traceback=True)
Converts an error object into a dictionary with keys for the error type and message. Optionally includes a traceback if with_traceback is set to True.
Parameters:
- error_object: The exception object to serialize.
- with_traceback (optional): Boolean flag to determine if traceback information should be included. Defaults to
True.
Returns:
- A dictionary containing the error type, message, and optionally the traceback.
Example:
try:
1 / 0
except Exception as e:
error_info = get_dict_of_error_object(e)
print(error_info)
get_json_of_error_object(error_object)
Converts an error object into a JSON string by utilizing get_dict_of_error_object.
Parameters:
- error_object: The exception object to serialize.
Returns:
- A JSON string representation of the error object.
Example:
try:
1 / 0
except Exception as e:
error_json = get_json_of_error_object(e)
print(error_json)
Installation
Install the package using pip:
pip install kr
This package can be a useful tool in applications where error handling and reporting are crucial, especially in environments where JSON is the preferred format for data interchange.
Release files for kr 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| kr-0.0.6.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kr-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:14.3 kB
Release files / kr-0.0.6.tar.gz
| Download URL | kr-0.0.6.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
905c79cfe14c650fff08553731eefd7439cdd31d5d4532d9e4a7ac3e80bc9e3f
|
|
BLAKE2b-256 checksum How to use checksums |
4e98bbd3f983d5e9f6e18587506f0507d2de826595bb5969e6613e6631ff130a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / kr-0.0.6-py3-none-any.whl
| Download URL | kr-0.0.6-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
530bf5032555673dd74a1645e199c7f3034618455e618e605dca8cd31fbdf29b
|
|
BLAKE2b-256 checksum How to use checksums |
9da51d40d7a861360c5c40b5211ba6b3a09cd7b0dbdeca0a606e7a89614ea985
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|