Skip to main content

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

  1. 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 /crash endpoint has an issue.

  2. Run the server with:

     fastapi dev main.py
    

    If you don't have the fastapi command follow instructions here.

  3. 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'
    
     Error detected, let's fix it!
     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


Download files

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

Source Distribution

crashless-0.0.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

crashless-0.0.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file crashless-0.0.4.tar.gz.

File metadata

  • Download URL: crashless-0.0.4.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for crashless-0.0.4.tar.gz
Algorithm Hash digest
SHA256 18df833fb27ea2dedf5c8aa0d70a53f0e5e0976b66a02618f8311ed25c4f65ba
MD5 6d107bc50df8d2063467d3409f8f50f8
BLAKE2b-256 9b8efb861a64ddb34dbceec483a8463bf18b0659aa5df38c4c899555d034b36c

See more details on using hashes here.

File details

Details for the file crashless-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: crashless-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.18

File hashes

Hashes for crashless-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a154e378831df4280aa70e2c5fa97e1343a57a8c69d81507e1eb1b0582fa0d33
MD5 e64578bf00c5b6dbcb41725f4f33afd3
BLAKE2b-256 02fbc9e0651c7496b3bf1252d2c7040c7b5aae52955c95a4baaf61d528d8ca56

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