Debug smarter, not harder! A comprehensive, cross-platform error handling and monitoring library that makes debugging enjoyable.
We believe error handling should be enjoyable, not frustrating! Debugg solves universal developer pain points:
- β Inconsistent error handling across different parts of applications
- β Lack of context when errors occur
- β No standardized severity levels
- β Multiple monitoring tools with different APIs
- β Cross-platform challenges
A single, unified library that provides:
- β Consistent error format across all platforms
- β Automatic error classification with severity levels
- β Rich context attachment for better debugging
- β Unique error IDs for tracking
- β Multiple reporter support (Sentry, webhooks, console, custom)
- β Cross-platform detection (Browser, Node.js, Mobile)
- β Type-safe API with comprehensive TypeScript support
- β Production-ready with security features
# Using npm
npm install debugg
# Using yarn
yarn add debugg
# Using Bun (recommended)
bun add debuggimport { debugg } from 'debugg';
// Debugg is ready to use with sensible defaults
try {
await riskyOperation();
} catch (error) {
await debugg.handle(error, {
userId: '123',
action: 'login',
});
}import { EnhancedErrorHandler, createConsoleReporter, createSentryReporter } from 'debugg';
const debugg = new EnhancedErrorHandler({
serviceName: 'my-awesome-app',
environment: process.env.NODE_ENV || 'development',
logToConsole: true,
security: {
redactFields: ['password', 'token', 'apiKey'],
enableRateLimiting: true,
},
});
// Add reporters
debugg.addReporter(createConsoleReporter());
if (process.env.SENTRY_DSN) {
debugg.addReporter(createSentryReporter(process.env.SENTRY_DSN));
}Enjoy beautiful, structured error handling! π
debugg.handle(new TypeError('...')); // β 'high' severity
debugg.handle(new SyntaxError('...')); // β 'critical' severity
debugg.handle(new Error('Network error')); // β 'high' (auto-detected)
debugg.handle({ status: 500 }); // β 'critical' severityawait debugg.handle(error, {
userId: user.id,
operation: 'update_profile',
database: 'postgresql',
query: 'UPDATE users SET name = $1',
parameters: ['John Doe'],
// Add anything that helps debugging!
});// Send errors everywhere
debugg.addReporter(createConsoleReporter());
debugg.addReporter(createSentryReporter('YOUR_DSN'));
debugg.addReporter(createWebhookReporter('https://api.example.com/errors'));const error = debugg.createError(new Error('test'));
console.log(error.metadata.platform);
// Returns: 'browser' | 'node' | 'mobile' | 'unknown'const debugg = new EnhancedErrorHandler({
security: {
redactFields: ['password', 'token', 'secret'],
maxContextSize: 1024 * 1024, // 1MB
enableRateLimiting: true,
maxErrorsPerMinute: 100,
sanitizeStrings: true, // XSS prevention
},
});// Error batching for high-traffic apps
const batcher = new ErrorBatcher({
maxBatchSize: 10,
flushIntervalMs: 5000,
});
// Error debouncing to prevent flooding
const debouncer = new ErrorDebouncer({
intervalMs: 1000,
maxBuffered: 10,
});- Quick Start Guide - Get started in 5 minutes
- API Documentation - Complete API reference
- Integration Guides - React, Vue, Express, Next.js
- Migration Guide - From other error handlers
- Troubleshooting - Common issues
- FAQ - Frequently asked questions
import { ErrorBoundary } from 'debugg/react';
<ErrorBoundary>
<App />
</ErrorBoundary>See React Integration Guide β
import { createExpressErrorHandler } from 'debugg/middleware/express';
app.use(createExpressErrorHandler(debugg));See Express Integration Guide β
import { withErrorHandler } from 'debugg/next';
export const getServerSideProps = withErrorHandler(async (context) => {
// Your code
});See Next.js Integration Guide β
| Reporter | Description | Installation |
|---|---|---|
| Console | Formatted console output | Built-in |
| Sentry | Sentry.io integration | bun add @sentry/node |
| Webhook | HTTP webhook endpoint | Built-in |
| Custom | Your own reporter | Built-in |
| Error Type | Severity | Description |
|---|---|---|
SyntaxError |
Critical | Code syntax issues |
TypeError |
High | Type-related errors |
ReferenceError |
High | Undefined variables |
RangeError |
Medium | Invalid ranges |
| Network errors | High | Connection issues |
| HTTP 5xx | Critical | Server errors |
| HTTP 4xx | Medium | Client errors |
import { ErrorReporter } from 'debugg';
const myReporter: ErrorReporter = async (error) => {
await fetch('https://my-service.com/errors', {
method: 'POST',
body: JSON.stringify(error),
headers: { 'Content-Type': 'application/json' },
});
};
debugg.addReporter(myReporter);// Get error metrics
const metrics = debugg.getErrorMetrics();
console.log(`Total errors: ${metrics.totalErrors}`);
console.log(`Resolution rate: ${metrics.resolutionRate}%`);
// Get mean time to debug
const mttd = debugg.getMeanTimeToDebug();
console.log(`Mean time to debug: ${mttd}s`);// Set baseline
debugg.setCIBaseline(10); // 10 errors in previous build
// Run quality gates
const result = await debugg.runCIQualityGates();
if (!result.passed) {
console.error('Quality gates failed:', result.message);
process.exit(1);
}Debugg is optimized for production:
- Error Creation: < 0.1ms per error
- Error Handling: < 1ms per error
- Memory Usage: < 1KB per error
- Bundle Size: ~73 KB (gzipped)
# Run tests
bun test
# Run with coverage
bun run test:coverage
# Run specific test suite
bun run test:integration
bun run test:e2e
bun run test:performance# Build library
bun run build
# Development mode
bun run dev
# Analyze bundle size
bun run build:size
# Verify tree-shaking
bun run build:verifyContributions are welcome! Please read our Contributing Guide for details.
# Clone repository
git clone https://github.com/your-org/debugg.git
cd debugg
# Install dependencies
bun install
# Start development
bun run dev
# Run tests
bun testMIT License - see LICENSE file for details.
- Inspired by developer pain points worldwide
- Built with love for the JavaScript/TypeScript community
- Designed to make error handling enjoyable
- Mascot: Debugg the Bug π - friendly, helpful
- Mission: Make error handling enjoyable
- Colors: Vibrant red (#FF4757) for energy
- Typography: Inter for clean readability
π₯ Ready to debug smarter? Install Debugg today!
bun add debuggStar this repository if you love debugging again! β