Problem/Motivation

When calling \Drupal\eca\Plugin\ECA\Modeller\ModellerInterface::save, we receive a boolean return value which indicates whether the model needs to be reloaded or not, i.e. if it was new or if the title got changed. As part of that method we also call \Drupal\eca\Service\Modellers::saveModel which actually saves the config entities. Potential errors are caught and written to the logger.

Other tasks like e.g. cloning a model, goes through similar steps but errors get displayed in the UI.

Proposed resolution

We should remove the try-catch from the saveModel method and handle exceptions in all other places that use that method directly or indirectly, depending on the context, and handle the feedback (message on screen or in log) appropriately.

CommentFileSizeAuthor
#4 error_message.png38.9 KBrkoller

Issue fork eca-3275457

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jurgenhaas created an issue. See original summary.

jurgenhaas’s picture

Assigned: jurgenhaas » Unassigned
Status: Active » Needs review

MR !130 is now handling exceptions consistently for all cases where ECA models get saved, e.g. save through ajax, import through form or Drush, cloning, enabling and disabling, etc. Each of those require specific handling of output to the user.

Side note: when going through all this, I thought we should probably have extracted all these functions into a submodule called ECA UI which could be enabled separately, just like views ui or fields ui. ECA as such could operate without any UI component perfectly, once the models are configured and deployed. Should we still go for that before 1.0? Doesn't seem to be a big deal, but may make another big difference to the architecture.

rkoller’s picture

StatusFileSize
new38.9 KB

I've applied the patch and tested it against the model the initial report was about. the error message isnt several screens long anymore. if you can confirm if those error message informations would be the only relevant and correct then i would consider the issue fixed:

error message about entering a valid address and an invalid regular expression

about your side note. i cant say anything about if it would be a reasonable step to create a separate ECA UI submodule, but if that is a significant change i wouldn't introduce something like that post 1.0 so the architecture would change another time right after a stable release .0 release.

i leave the issue status at needs review so others could chime in about the side note question and in regards if the display issue is fixed.

mxh’s picture

Side note: when going through all this, I thought we should probably have extracted all these functions into a submodule called ECA UI which could be enabled separately, just like views ui or fields ui.

Good idea, we could then move all list builders, controllers, form objects and maybe even permissions into that sub-module. The ECA config entity may then be extended by this module via hook_entity_type_build, similar as field_ui does it.

jurgenhaas’s picture

Merged latest changes from 1.0.x-dev here too for better review.

mxh’s picture

Code looks good, haven't tested this one manually though as @rkoller obviously already did it :)

The only thing that raised a question mark was why we check for \LogicException and EntityStorageException but nothing else. But since no other type of error was detected I guess it's good to go.

mxh’s picture

Status: Needs review » Reviewed & tested by the community

We could address ECA UI within its own issue.

  • jurgenhaas committed 0b888ab on 1.0.x
    Issue #3275457 by jurgenhaas, rkoller, mxh: Error handling inconsistent...
jurgenhaas’s picture

Status: Reviewed & tested by the community » Fixed

Also, thanks so much for this one @mxh and @rkoller

The LogicException hit me a couple of times when there have been schema violations or missing plugins somewhere in the Drupal installation. They are not documented, I just discovered them by debugging the code.

And yes, let's address ECA UI in a separate issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.