Improve form loading error handling

Created on 24 January 2024, 5 months ago
Updated 23 February 2024, 4 months ago

Problem/Motivation

When the form can't be loaded, the message logged on drupal log misses the exception message details. Also, "Form failed to load" message is not suitable for some customers who are concerned of lead income loses.

Steps to reproduce

When a form can't be loaded. Can be simulated by adding the following code inside the "try" inside `getFormMarkup` function:

throw new \UnexpectedValueException(
  "Example exception",
  500
);

Proposed resolution

  • Also log the exception message
  • Allow users to configure a custom error message when forms can't be loaded into a new module's settings form. This message should be translatable in multilingual sites. Another option would be to change the "Form failed to load." with "Sorry, there was a problem loading the form. Please try again later."

Remaining tasks

  • Let the configuration form field "Error message when forms fails to load" be translatable
  • Load the configuration value for the current language and print it in case of error

User interface changes

New configuration form.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain rcodina

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024