GDevelop-extensions
GDevelop-extensions copied to clipboard
Refactor and Bug Fixes for Promise Handling and Validation
Is there an existing issue for this?
- [X] I have searched the existing issues
Enter the name of the extension
Promise Handling & Validation Refactor
Describe the bug of the extension
The current implementation of some key functions in the extension (such as verifyExtension.js and extract-extension.js) lacks consistent error handling and validation. This can lead to unhandled promise rejections, improper error reporting, and potential crashes when incorrect inputs are provided.
Steps to reproduce
- Go to the extension's folder.
- Attempt to load a zip file or JSON file with invalid names or structures.
- Observe inconsistent error handling or crashes.
- In some cases, file extraction might fail silently or without proper error messages.
GDevelop platform
Desktop
GDevelop version
5.1.160
Platform info
OS: Windows, Linux, macOS
OS Version: Windows 10, macOS 11.0
Browser (for Web): Chrome, Firefox
Device (for Mobile): N/A
Additional context
The refactor applies consistent async/await
promise handling, improves type checking, and combines redundant loops in various scripts:
-
verifyExtension.js
: Introduced atry-catch
block for proper async error handling, added logging, and improved the flow of promise-based error management. -
extract-extension.js
: Wrapped operations in atry-catch
block to streamline promise handling, preventing unhandled rejections. -
ExtensionNameValidator.js
: Added string validation for the extension name to avoid runtime errors from invalid inputs. -
PascalCase.js
: Combined loops to reduce code duplication and added type checking to ensure extension names are valid strings.
This improves the overall robustness of the extension and prevents crashes or silent failures in several key processes.