[Refactor]: Better error messages and experience#159
Merged
Conversation
- Implement error reporter module with PostHog client - Configure for short-running CLI tools (immediate flush, no batching) - Integrate error reporting in bin/run.js with proper shutdown - Add environment variable configuration (POSTHOG_API_KEY, POSTHOG_HOST) - Include error context (command, Node version, platform) - Add unit tests for error reporter - Graceful degradation when PostHog is not configured Resolves #55 Co-authored-by: Kfir Stri <kfirstri@users.noreply.github.com>
Contributor
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/cli@0.0.25-pr.159.7480a31Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/cli@0.0.25-pr.159.7480a31"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/cli@0.0.25-pr.159.7480a31"
}
}
Preview published to npm registry — try new features instantly! |
f2e9cd8 to
9a8c9ae
Compare
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Collaborator
Author
|
This PR Still doesn't add better errors for API client, we will add it after #135 is merged, then we can throw the nicer errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a comprehensive error handling system that replaces generic error throws with a structured error hierarchy. The new system distinguishes between user-fixable errors (
UserError) and system errors (SystemError), provides actionable hints with optional commands for AI agents, and improves telemetry tracking with error codes and classification. This refactor enhances developer experience by making errors clearer and more actionable across the entire codebase.Related Issue
None
Type of Change
Changes Made
CLIErrorbase class with two main branches:UserError(user-fixable issues like auth/config problems) andSystemError(system issues like API/file failures)AuthRequiredError,AuthExpiredError,ConfigNotFoundError,ConfigInvalidError,ConfigExistsError,SchemaValidationError,InvalidInputError,ApiError,FileNotFoundError,FileReadError,InternalError{ message: "Run 'base44 login'", command: "base44 login" }) to guide users and AI agentsSchemaValidationErrorautomatically formats validation errors usingz.prettifyError()for better readabilityerror_codeandis_user_errorproperties in PostHog for better analytics and debugging (src/cli/telemetry/error-reporter.ts:366-377)throw new Error()isCLIError(),isUserError(), andisSystemError()type guards for error handlingAuthApiErrorandAuthValidationErrorwith new structured errorsTesting
npm test)Checklist
Additional Notes
This refactor significantly improves the developer experience by providing clear, actionable feedback when errors occur. The distinction between
UserErrorandSystemErrorhelps with debugging, prioritizing fixes, and providing better user guidance. The structured hints system is particularly valuable for AI agents that can now automatically suggest and execute recovery commands. All error messages now follow consistent patterns and include helpful context for resolution.Key architectural improvements:
🤖 Generated by Claude | 2026-01-31 09:54 UTC