Add exitCode property as alias for code in error objects#110
Open
konard wants to merge 3 commits into
Open
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #38
This change addresses issue #38 by adding error.exitCode as an alias for error.code to maintain compatibility with Node.js standard error handling patterns while preserving backward compatibility. Changes: - Add error.exitCode property alongside error.code in all error creation locations - Fix $.exit.mjs virtual command to throw proper Error objects instead of plain objects - Add comprehensive tests for exitCode compatibility - Add example script demonstrating both old and new error handling patterns Both error.code and error.exitCode now contain the same exit code value, allowing developers to use either the traditional command-stream pattern or the standard Node.js pattern. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
🤖 AI-Powered Solution
This pull request automatically solves issue #38 by adding
error.exitCodeas an alias forerror.codeto maintain compatibility with Node.js standard error handling patterns.📋 Issue Reference
Fixes #38
🔧 What Changed
Core Implementation
error.exitCodeproperty: All error objects now include botherror.codeanderror.exitCodewith the same valueexitcommand: Now throws proper Error objects instead of plain objectserror.codecontinues to work unchangedModified Files
src/$.mjs: Addederror.exitCode = <code>alongside everyerror.code = <code>assignmentsrc/commands/$.exit.mjs: Fixed to throw proper Error objects with both propertiestests/exitcode-compatibility.test.mjs: Comprehensive test suite for both patternsexamples/test-exitcode-compatibility.mjs: Demonstration script showing compatibility✅ Solution Details
The fix implements Option 1: Add Alias (Backward Compatible) from the issue description:
🧪 Testing
All error scenarios now provide both properties:
Test Coverage:
error.codeusageerror.exitCode📊 Compatibility Matrix
error.exitCodeerror.exitCodeerror.exitCodeerror.codeerror.code+error.exitCode🚀 Impact
This change enables:
This PR was automatically generated and tested by the AI issue solver