Skip to content

refactor TryCatch implementation for improved error handling #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BAKAOLC
Copy link
Collaborator

@BAKAOLC BAKAOLC commented May 15, 2025

This pull request refactors and enhances the plus.TryCatch function in game/packages/thlib-scripts/plus/Utility.lua. The changes improve maintainability, readability, and error handling by restructuring the implementation and adding detailed type annotations.

Refactoring and Enhancements to plus.TryCatch:

  • Refactored function implementation: Replaced the original plus.TryCatch function with a more modular and structured approach, utilizing helper functions (innerFunc, innerCatchFunc, and packageResult) for better readability and maintainability.
  • Added type annotations: Introduced a plus.TryCatch.Data class with type annotations for try, catch, and finally functions, ensuring clearer documentation and stricter type checking.
  • Improved error handling: Enhanced error messages by including detailed inner tracebacks for both try and catch blocks, and ensured proper propagation of unhandled errors.
  • Preserved functionality: Maintained the original behavior of executing finally blocks after try or catch blocks, ensuring compatibility with existing usage.

These changes make the plus.TryCatch function more robust and easier to understand while preserving its core functionality.

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