GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

Refactor and Bug Fixes for Promise Handling and Validation

Open Viole07 opened this issue 4 months ago • 0 comments

Is there an existing issue for this?

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

  1. Go to the extension's folder.
  2. Attempt to load a zip file or JSON file with invalid names or structures.
  3. Observe inconsistent error handling or crashes.
  4. 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 a try-catch block for proper async error handling, added logging, and improved the flow of promise-based error management.
  • extract-extension.js: Wrapped operations in a try-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.


Viole07 avatar Oct 09 '24 14:10 Viole07