@plasius/error
v1.0.10
Published
Error handling functions and types for Plasius projects
Readme
@plasius/error
Public package containing shared error boundary and error-handling utilities for Plasius React applications.
Install
npm install @plasius/errorModule formats
@plasius/error ships dual module outputs:
- ESM via
exports.import(dist/index.js) - CJS via
exports.require(dist-cjs/index.js, explicitly marked CommonJS)
Usage
import { ErrorBoundary } from "@plasius/error";Error reporting with @plasius/analytics
ErrorBoundary can forward captured errors into an analytics-compatible client:
import { ErrorBoundary } from "@plasius/error";
import { createFrontendAnalyticsClient } from "@plasius/analytics";
const analytics = createFrontendAnalyticsClient({
source: "sharedcomponents",
endpoint: "https://analytics.example.com/collect",
});
<ErrorBoundary
name="CheckoutBoundary"
analyticsClient={analytics}
errorContext={{ feature: "checkout" }}
>
<CheckoutPage />
</ErrorBoundary>;The boundary forwards a minimal report (boundary, error, component stack, severity, context), and @plasius/analytics handles sanitization and secure transport rules.
Whole application crash capture
installGlobalCrashReporter captures crashes outside React boundaries where available:
- browser:
window.error,window.unhandledrejection - server/runtime:
process.uncaughtException,process.unhandledRejection
import {
ErrorBoundary,
installGlobalCrashReporter,
} from "@plasius/error";
const crashReporter = installGlobalCrashReporter({
boundaryName: "GlobalApplication",
analyticsClient: analytics,
errorContext: { app: "frontend" },
});
// later during teardown
crashReporter.dispose();Development
npm ci
npm run build
npm testGovernance
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- ADRs: docs/adrs
- Legal docs: legal
License
MIT
