Skip to main content

A simple library for decorating functions that can raise exceptions.

Project description

can-raise

A simple library for decorating functions that can raise exceptions.

Installation

pip install can-raise

Usage

from can_raise import can_raise

@can_raise(ValueError)
def validate_int(x: int):
    if x < 0:
        raise ValueError
    return x

If you don't provide any value, it will default to Exception

@can_raise()
def raise_exc():
    raise TypeError # or any other exception

You can also provide more than one argument

@can_raise(ValueError, TypeError)
def raise_exc(x: int):
    if x < 0:
        raise ValueError
    if x > 0:
        raise TypeError
    return x

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

can_raise-0.1.8.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

can_raise-0.1.8-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file can_raise-0.1.8.tar.gz.

File metadata

  • Download URL: can_raise-0.1.8.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for can_raise-0.1.8.tar.gz
Algorithm Hash digest
SHA256 cb454f0056080b3867af92694fa6de9884da51307d12ca35ec81c9de49d9bd27
MD5 9d0d64645a8616a40107ac8177648f5c
BLAKE2b-256 bbca739bd1f116adf0d063562cbb89cb57da2e07991e2ad840de3f76814cb0e7

See more details on using hashes here.

File details

Details for the file can_raise-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: can_raise-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for can_raise-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 94a58f91fc5781a331ece1f7f743913c032d6eff2043e8a30507c8d0bcf3adf7
MD5 156031c8f23c6609a2c0b2802b9d41b1
BLAKE2b-256 a888a1cdf40ea0d365214ab3cedc8de147d615d6ecbb9cdc0ba692d4bac920a3

See more details on using hashes here.

Supported by

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