Skip to main content

fexception is designed to provide cleaner useable exceptions.

Project description

fexception

fexception is designed to provide cleaner useable exceptions. The "f" in fexception represents formatted.

Description

fexception includes every built-in Python exception and adds the ability to wrap a clean formatted structure around the exception. Each formatted ("f") exception can add up to five different types of exception input into the formatted exception. fexception has multiple traceback return options.

fexception's operates like built-in Python exceptions. You raise the exception when needed, and the exception will get formatted. All raised exceptions will source and trackback from the original raised location. fexception supports nested formatted messages.

fexception offers three traceback options that can enable/disable with boolean attributes.

  1. One level of traceback.
  2. Full traceback.
  3. No traceback information.

fexception offers five message keys to format the exception to your liking. Three keys provide string or list values to format multiple lines cleanly. Each exception message must be in dictionary format. Use the table below to set the formatted exception message.

Key Type Optional Value
main_message str no The main exception message.
expected_result str or list yes The expected result message. (str: single line) or (list: individual split lines)
returned_result str or list yes The returned result message. (str: single line) or (list: individual split lines)
suggested_resolution str or list yes A suggested resolution message. (str: single line) or (list: individual split lines)
original_exception Exception yes A caught exception for additional details.

fexception includes a custom exception class that is not part of the built-in Python exceptions. This exception is called FCustomException. This exception is unique because it can add custom exceptions to the formatted message. When the exception is returned, the exception will return as your custom exception class. This class is the only class that has a possibility of six keys. The required key for this custom class is called custom_type.

Examples

Example1:

exec_args = {
 'main_message': 'Incorrect value was sent.',
 'expected_result': '5',
 'returned_result': '2',
 'suggested_resolution': 'Check the input source.',
}
raise FValueError(exec_args)

Example2:

exec_args = {
 'main_message': 'Incorrect value was sent.',
 'expected_result': '5',
 'returned_result': '2',
 'suggested_resolution': 'Check the input source.',
 'custom_type': MySampleException,
}
raise FCustomException(exec_args)

Installation

From PyPI

You can find fexception on PyPI. https://pypi.org/project/fexception/

Usage

Once installed, add fexception as a module and select the formatted exception option from the import.

Note: You can use * to import all formatted exception options.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fexception-0.2.tar.gz (14.0 kB view details)

Uploaded Source

File details

Details for the file fexception-0.2.tar.gz.

File metadata

  • Download URL: fexception-0.2.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for fexception-0.2.tar.gz
Algorithm Hash digest
SHA256 8c9fc2a9b6c088a0104a53b05c62b94d5de0e5548537001d8480c947681ea14a
MD5 5cfcf6d5f8ccfbb8ede5bde28019bb87
BLAKE2b-256 3e21e76a9f1b7521bc9923011ac2ab56988233061387ed4a31629ecfac339771

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page