Skip to main content

Catch fatal errors or any type of error, used to easily normalize executions in swift calls with PythonKit

Project description

guard_exception

- guard all exception for swift run python

install

- pip install guard-exception

example

import guard_exception as ge

gg = ge.guard_exception()


def dividir(a, b):
    return a / b


print(gg.guardException(dividir, a=1, b=0))


# result cli
# {'data:': None, 'error': 'division by zero'}

example on swift with PythonKit

import PythonKit
let hvac = Python.import("hvac")
let ge = Python.import("guard_exception")
let gg = ge.guard_exception()

let client = hvac.Client(url: "http://0.0.0.0:8200")

let user = "incorrect_user"
let params = Python.dict()
params["username"] = PythonObject(user)
params["password"] = PythonObject("incorrect_password")

print(gg.guardException(client.login, url: "v1/auth/userpass/login/\(user)", use_token: true, json: params))

// result: cli
//{'data:': None, 'error': 'invalid username or password, on post http://0.0.0.0:8200/v1/auth/userpass/login/incorrect_user'}

Download files

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

Source Distribution

guard_exception-1.0.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

guard_exception-1.0.0-py3-none-any.whl (3.3 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