Overview
Browser Debugger CLI uses semantic exit codes to enable reliable automation and agent-friendly error handling. Exit codes follow predictable ranges that indicate the category and severity of errors.Exit codes are stable API - values will not change in minor versions. Safe to use in automation scripts and CI/CD pipelines.
Exit Code Ranges
| Range | Category | Meaning | Retry Strategy |
|---|---|---|---|
0 | Success | Command completed successfully | - |
1 | Generic Failure | Legacy/backward compatibility | Avoid in new code |
80-99 | User Errors | Invalid input, permissions, missing resources | Fix input and retry |
100-119 | Software Errors | Bugs, timeouts, integration failures | Investigate or report |
Philosophy
User Errors (80-99)
Problems caused by incorrect usage, invalid input, or environmental constraints. The user can fix these by adjusting their command or environment. Examples:- Invalid URL format
- File not found
- Insufficient permissions
- Resource already exists
Software Errors (100-119)
Problems caused by bugs, external service failures, or unexpected conditions. Requires investigation by developers or may resolve with retry. Examples:- Chrome launch failure
- CDP connection timeout
- Unhandled exception
- Session file corruption
Complete Reference
Success
Operation completed successfullyExample:
Generic Failure
Generic failure (backward compatibility)Note: Use specific codes (80-119) in new code. This exists for backward compatibility.Example:
User Errors (80-99)
Invalid URL format or unreachable URLExample:
Invalid command-line arguments or optionsExample:Common Cases:
- Unknown flags
- Invalid flag values
- Missing required arguments
- Type mismatches (e.g., string where number expected)
Insufficient permissions for operationExample:
Requested resource not found (session, file, element, etc.)Example:Common Cases:
- No active session
- Element not found (DOM query)
- Network request ID not found
- File does not exist
Resource already exists (duplicate session, etc.)Example:
Resource is locked or busyExample:
Daemon is already runningExample:Note: Rarely seen by users - handled internally during daemon startup.
Cache invalidated by navigation or DOM changesExample:Important: This is distinct from
RESOURCE_NOT_FOUND (83) - it indicates the element existed but is now stale due to DOM changes.No forms discovered on the pageExample:
Form is inside an iframe (cross-origin or same-origin)Example:
Software Errors (100-119)
Chrome browser failed to launchExample:Common Causes:
- Chrome not installed
- Port conflict (9222 already in use)
- Missing dependencies (Linux)
- Insufficient resources
Failed to connect to Chrome DevTools ProtocolExample:Common Causes:
- Chrome crashed after launch
- WebSocket endpoint unreachable
- Network/firewall issues
CDP operation timed outExample:Common Causes:
- Page unresponsive
- Infinite loop in JavaScript
- Network latency
- Heavy computation blocking event loop
Session file read/write errorExample:Common Causes:
- Disk full
- File system corruption
- Permission changes during session
Unhandled exception in codeExample:Note: This indicates a bug. Please report with full error message.
Signal handler errorExample:Note: Rare - indicates cleanup failure during shutdown.
Generic software error (use specific codes when possible)Example:Note: Use more specific codes (100-109) when possible.
Usage in Automation
Shell Scripts
Python
CI/CD (GitHub Actions)
JSON Output
When using--json flag, exit codes are included in error responses:
Discovering Exit Codes
Usebdg --help --json to get machine-readable documentation including all exit codes:
Stability Guarantees
Exit codes are stable public API
Versioning Policy
- ✅ Exit code values will not change in minor versions
- ✅ New exit codes may be added in minor versions (within ranges)
- ✅ Exit code semantics (meaning) remain consistent
- ⚠️ Existing codes only removed in major versions with deprecation notice
Migration Policy
- Deprecated codes documented in CHANGELOG.md
- Deprecated codes functional for at least one major version
- Clear migration path provided
Source Code
Definition:src/utils/exitCodes.ts
Related Documentation
Architecture
Understanding bdg’s process model
Troubleshooting
Common errors and diagnostic commands

