Bugless future for our sanity sake
Project description
Crashless
Crash proof your code
Crashless enables you to catch those pesky bugs during backend development and correct them in real-time. Makes your development cycle smooth, so you can actually focus on building what actually matters.
Installation
Crashless is published as a Python package and can be installed with pip, ideally by using a virtual environment. Open up a terminal and install Crashless with:
pip install crashless
Add to FastAPI in 3 steps
-
Copy and paste the following server with a crashed endpoint to a file called
main.py:from fastapi import FastAPI app = FastAPI() @app.get("/") def read_root(): return {"message": "The server is running OK!"} @app.get("/crash") # This endpoint has a fatal bug :( def crash(): result = 8 + '7' return {'msg': f"Summing a+b = {result}"} # Adds Crashless import sys from crashless import fastapi_handler # Imports library def in_dev_mode(): """Knows if you are running in production or development mode""" return sys.argv[1] == 'dev' if in_dev_mode(): # If in dev mode adds an exception handler, that will suggest a possible fix. app.add_exception_handler(Exception, fastapi_handler.handle_exception)As you can see the
/crashendpoint has an issue. -
Run the server with:
fastapi dev main.pyIf you don't have the fastapi command follow instructions here.
-
Go to http://127.0.0.1:8000 and check that it's running OK.
Then go to http://127.0.0.1:8000/crash and see how it crashes.
Now go to the terminal, where the server is running, and you'll see something like this:
TypeError: unsupported operand type(s) for +: 'int' and 'str' Crashless detected an error, let's fix it! Loading possible solution... The following code changes will be applied: @app.get("/crash") # This endpoint has a fatal bug :( def crash(): - result = 8 + '7' + result = 8 + int('7') return {'msg': f"Summing a+b = {result}"} Explanation: The error occurred because you cannot add an integer and a string directly. The fix converts the string '7' to an integer using int('7') before performing the addition.You can apply changes by ENTERING a
y. The changes will take place and the api reloads. If you try again you get 15!
Add to Django in 3 steps
coming soon!
Add to Flask in 3 steps
coming soon!
Links
Source Code: https://github.com/jisazaTappsi/crashless
Python library: https://pypi.org/project/crashless/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crashless-0.0.8.tar.gz.
File metadata
- Download URL: crashless-0.0.8.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
434c883dc9006ed2bc4bf7bb8aeb2925a4c38e5b1788664ad398616b834cfea2
|
|
| MD5 |
c3e2465fca3ac0e4b18497afc3ee5b72
|
|
| BLAKE2b-256 |
b4830149ac2840b65b69feafcb62b94ca79661a8a64a8ad21a9cbe52dc1a54d2
|
File details
Details for the file crashless-0.0.8-py3-none-any.whl.
File metadata
- Download URL: crashless-0.0.8-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b797fa2f8cc38f26d7d62d45f0e0ebc6ac782329dd5bf13b6b37fc0bd57db30
|
|
| MD5 |
415d39df010ef631dbcb0de3af47ccaf
|
|
| BLAKE2b-256 |
a66bae8e703a8120db7be7213cfe2d6e2a50c83b6b31baca4e43f7208c6d78f5
|