Improve error handling in import/export plugins during imports and exports

Created on 21 July 2024, 5 months ago

System information

  • Drupal Core Version: ^10.2 || ^11
  • Menu Migration Version: 4.0.0-alpha2
  • PHP Version: >= 8.1 || <= 8.3

Problem/Motivation

Currently, there is no way for the export/import plugins to pass along detailed error messages when something goes wrong during exports/imports. In some cases, like the Codebase import, if the plugin attempts to import a non-existent menu, there will be a PHP warning that the file could not be opened or does not exist. In other cases, no other error messages are being displayed, besides the general message of import failed menus.

Steps to reproduce

An example for the non-existent files:
1. Create an Import Type
2. Set the Source to Codebase
3. Select one or more menus
4. Configure the import path to something empty
5. Observe the behaviour

Proposed resolution

Add a way to add additional detailed error messages in the exportMenu() and importMenu() methods.
The solution will contain a new custom Exception called MenuMigrationException which will be thrown from these two methods, and the parent import() and export() methods will catch and register the error messages in the final result array.

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇷🇴Romania bbu23

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024