Skip to main content

Beautiful debugging page for Starlette apps.

Project description

Starception

Beautiful exception page for Starlette and FastAPI apps.

PyPI GitHub Workflow Status GitHub Libraries.io dependency status for latest release PyPI - Downloads GitHub Release Date

Installation

Install starception using PIP or poetry:

pip install starception
# or
poetry add starception

With syntax highlight support

If you want to colorize code snippets, install pygments library.

pip install starception[pygments]
# or
poetry add starception -E pygments

Screenshot

image

Dark theme

Features

  • secrets masking
  • solution hints
  • code snippets
  • display request info: query, body, headers, cookies
  • session contents
  • request and app state
  • platform information
  • environment variables
  • syntax highlight
  • open paths in editor (vscode only)
  • exception chains
  • dark theme

Starception automatically masks any value which key contains key, secret, token, password.

Quick start

See example application in examples/ directory of this repository.

Usage

Starception will work only in debug mode so don't forget to set Starlette.debug=True.

To replace built-in debug exception handler call install_error_handler before you create Starlette instance.

from starception import install_error_handler
from starlette.applications import Starlette

install_error_handler()
app = Starlette()

Integration with other frameworks

starception exports starception.exception_handler(request, exc) function, which you can use in your framework. But keep in mind, Starlette will not call any custom exception handler in debug mode (it always uses built-in one).

The snipped below will not work as you expect (unfortunately).

from starlette.applications import Starlette

from starception import exception_handler

app = Starlette(
    debug=True,
    exception_handlers={Exception: exception_handler}
)

Solution hints

If exception class has solution attribute then its content will be used as a solution hint.

class WithHintError(Exception):
    solution = (
        'The connection to the database cannot be established. '
        'Either the database server is down or connection credentials are invalid.'
    )

image

Opening files in editor

Set your current editor to open paths in your editor/IDE.

from starception import set_editor

set_editor('vscode')

image

Note, currently only VSCode supported. If you know how to integrate other editors - please PR

Registering link templates

If your editor is not supported, you can add it by calling add_link_template and then selecting it with set_editor.

from starception import set_editor, add_link_template

add_link_template('vscode', 'vscode://file/{path}:{lineno}')
set_editor('vscode')

Credentials

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

starception-1.2.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

starception-1.2.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file starception-1.2.1.tar.gz.

File metadata

  • Download URL: starception-1.2.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1039-azure

File hashes

Hashes for starception-1.2.1.tar.gz
Algorithm Hash digest
SHA256 b5a9a2b44b50ea795456018da3da98900001b9962ba68723715356bc59903797
MD5 a294e02a79eefb6f2fb89eb0303af997
BLAKE2b-256 189bd0d3bc75474fcd7d0024572c524d86314144287cf97c603cff4ebd11968a

See more details on using hashes here.

File details

Details for the file starception-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: starception-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1039-azure

File hashes

Hashes for starception-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d083c5ca655a33baf9dad4d2057c33530111168c1de7f765b3aa7727fc852aa
MD5 d4d34f7d64fb5346b41857ce81a7fc66
BLAKE2b-256 03b05cd9a1b5332e66c16034b3c46feb74f54c9f753f14ed0c93221f87dd43c3

See more details on using hashes here.

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