Skip to main content

No project description provided

Project description

basic-return

Manage function returns with a generic class

PyPI version Build status GitHub stars Support Python versions

Getting started

You can get basic-return from PyPI, which means it's easily installable with pip:

python -m pip install basic-return

Example usage

from basic_return.BasicReturn import BasicReturn
def function(a, b, c=30, d=50):
    br = BasicReturn()

    if a < 10:
        br.status = 10
        br.message = "param a is less than 10"
        br.payload = {"something": 123456789}
        return br

    if b > 20:
        br.status = -10
        br.message = "param b is bigger than 20"
        return br

    br.status = 20
    br.message = "param a is less than 10"
    return br

br = function(10, 20, d=40)
if br.status < 0:
    print(br.owner_call)  # function(a=10, b=20, c=30, d=40); this is how the function was called so we can replicate the error
    raise Exception(f"Something bad happens: [{br.status}] - {br.message}")

Changelog

Refer to the CHANGELOG.md file.

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

basic_return-0.1.0.11.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

basic_return-0.1.0.11-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

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