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'}
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
guard_exception-1.0.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for guard_exception-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 207fa1a87017f2c56e16417ff951d2f129f5b81ce6190556fd909efd9fdd7432 |
|
MD5 | 1b580e25e65a7702703aae4166d8768e |
|
BLAKE2b-256 | 6e87e31d403f4f68eada8725151540cc5d7b413e9e65e88e878ca1e6b327e8ef |