FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

pythonnative/docs/api/diagnostics.md at v0.43.1 · pythonnative/pythonnative · GitHub

Repository navigation

Latest commit

 

History

History
39 lines (31 loc) · 1.32 KB

File metadata and controls

39 lines (31 loc) · 1.32 KB

Diagnostics

Developer-mode warnings and error reporting. This module powers the feedback you get while developing: [PN] WARN messages for suspicious props and styles, the [HookOrderError][pythonnative.HookOrderError] raised on conditional hooks, and the RedBox overlay that surfaces uncaught errors from renders, effects, and event handlers.

Dev mode is enabled automatically by pn start / pn preview and in the debug builds pn run produces, or explicitly with the PN_DEV=1 environment variable. In production builds every check in this module is skipped, so shipping apps pay no overhead.

import pythonnative as pn

if pn.diagnostics.is_dev():
    pn.diagnostics.warn("fetching from a staging endpoint")

Most apps never call this module directly; it exists so framework code (and custom component libraries) can report problems in a way that reaches the developer instead of disappearing into a log.

::: pythonnative.diagnostics options: show_root_heading: false show_root_toc_entry: false members_order: source filters: ["!^_"]

Next steps

  • Catch render errors in the tree with [ErrorBoundary][pythonnative.ErrorBoundary]: see the Error boundaries guide.
  • The rules of hooks and what HookOrderError means: Hooks.

Back | FazBrowse Home | New Git URL