Skip to content

Conversation

@aapsi
Copy link
Contributor

@aapsi aapsi commented Oct 19, 2025

PR Summary: Add Consistent Error Handling to TypeScript Scripts

Title:

Add consistent error handling to all TypeScript scripts

Description:

This PR addresses an inconsistency in error handling across the TypeScript scripts in the repository. Previously, some scripts had proper error handling while others would crash with unhandled promise rejections.

Problem:

  • Scripts had inconsistent error handling patterns
  • Some scripts would crash with cryptic errors instead of failing gracefully
  • Mixed patterns made the codebase unpredictable for developers

Solution:

Added .catch() error handling to all scripts that were missing it, ensuring:

  • Scripts fail gracefully with clear error messages
  • Proper exit codes are returned when scripts fail
  • Consistent behavior across all TypeScript scripts

Changes Made:

  • Files Modified: 5 TypeScript scripts
  • Added: .catch() error handling to scripts that were missing it
  • Pattern: Consistent error handling using console.error() and process.exit(1)

Files Changed:

  • scripts/deploy_account.ts - Added error handling to deployAccount() call
  • scripts/fees.ts - Added error handling to main() call
  • scripts/get_block.ts - Added error handling to main() call
  • scripts/multiple_pxe.ts - Added error handling to main() call
  • scripts/profile_deploy.ts - Added error handling to main() call

Before:

// Scripts would crash with unhandled promise rejections
main();

After:

// Scripts now fail gracefully with proper error handling
main().catch((error) => {
    console.error("Error:", error);
    process.exit(1);
});

Impact:

  • Improved Developer Experience: Scripts fail gracefully instead of crashing
  • Better Reliability: Consistent error handling across all scripts
  • Professional Quality: Scripts return proper exit codes for CI/CD usage
  • Easier Debugging: Clear error messages when scripts fail

Testing:

  • All scripts maintain their original functionality
  • Error handling follows existing codebase patterns
  • No breaking changes to script behavior
  • Consistent with scripts that already had error handling

Type of Change:

  • Code quality improvement
  • Bug fix (handles unhandled promise rejections)
  • New feature
  • Breaking change

Why This Matters:

This change standardizes error handling across the entire script collection, making the codebase more professional and predictable for developers using these scripts as examples or in their own projects.

- Add .catch() error handling to scripts that were missing it
- Ensures all scripts fail gracefully with proper exit codes
- Improves consistency across the codebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant