Skip to main content

Lightweight error notifier for hobby Python projects

Project description

ml3error

A tiny error notifier for hobby Python projects. When your program crashes, it sends you a message on Telegram, Slack, or email — and won't buzz your phone again for the same error until tomorrow.

Built for personal bots, home-server scripts, and small apps where pulling in Sentry is overkill. Single runtime dependency (notifiers), SQLite for state (Redis optional), no external services beyond your chosen transport.

Install

uv add ml3error

Use it

Recommended: keep credentials out of code. Drop a .env next to your script:

ML3ERROR_TRANSPORT=telegram
ML3ERROR_TRANSPORT_TOKEN=1234567890:ABCdef-your-bot-token
ML3ERROR_TRANSPORT_CHAT_ID=123456789

Then in your code:

import ml3error
ml3error.init()

That's it. .env is loaded automatically (via python-dotenv). Shell-exported vars still take precedence, so uv run --env-file .env python your_script.py also works. See .env.example for the full set of recognized names.

From now on, any uncaught exception gets scrubbed for PII, fingerprinted, and sent to you. Repeated errors with the same fingerprint are grouped and suppressed for 24h by default. A once-a-day heartbeat tells you everything is still running.

You can also report caught exceptions manually:

try:
    risky_thing()
except Exception as e:
    ml3error.report(e)

Programmatic config (alternative)

If you'd rather not use env vars, every option takes an init() kwarg:

ml3error.init(
    transport="telegram",
    transport_config={"token": "...", "chat_id": "..."},
    cooldown_hours=12,
)

Kwargs win over env vars when both are set.

Verify once

Call ml3error.ping() after init() the first time to confirm your credentials work — it sends a synthetic message and raises if the transport refuses.

Review UI

ml3error ships with a minimal web UI to review the errors you've been notified about and mark them resolved:

uv run ml3error

Opens http://127.0.0.1:6025 in your browser. State comes from .env / env vars, or pass --state sqlite:///path.db explicitly.

Preview the daily digest

The library sends a once-a-day heartbeat listing your most active errors, their counts, and how recently they fired. To see what that looks like on demand (e.g., after wiring up a new transport):

uv run ml3error heartbeat

Sends the same message the scheduled thread would send, using your configured transport. This is a pure preview — it does not advance last_heartbeat or reset counters, so the scheduled daily firing still happens normally.

What it doesn't do

  • No structured context, breadcrumbs, or sampling — use Sentry if you want those.
  • No framework auto-instrumentation.
  • No retries on transport failures (one attempt, counted in the next heartbeat).

More

Full design and behavior details live in SPEC.md. Runnable end-to-end examples are in examples/.

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

ml3error-0.1.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

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

ml3error-0.1.0-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file ml3error-0.1.0.tar.gz.

File metadata

  • Download URL: ml3error-0.1.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for ml3error-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ea8b0eec93eef9c7e010692e8e5bda2b79d3b1108ba82f7bf4cb90dbf1b3e9f
MD5 9f06eda0c5e476472be28f60b2602384
BLAKE2b-256 9fb1085b860559639a5459509594cf0a56b720b595a7906ac56628491fb5f064

See more details on using hashes here.

File details

Details for the file ml3error-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ml3error-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for ml3error-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebbee2ef23b7d4edff8b838e37cffe486242729a1be6692920df1a6460e1ef61
MD5 b3951a20befba512fc2da2d9dd67cf7b
BLAKE2b-256 cd01b7a904a86b48f66ccd782d625161cde37653394a417ae503090e0153ba68

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