Skip to content

Feature Request: Hard Failure (in Developer Mode) for Layout Handle XML Errors  #2399

@astorm

Description

@astorm

Existing Behavior: When Magento 2 encounters a parsing error in a layout handle XML file, it logs the error here.

#File: lib/internal/Magento/Framework/View/Model/Layout/Merge.php
protected function _logXmlErrors($fileName, $libXmlErrors)
{
    $errors = [];
    if (count($libXmlErrors)) {
        foreach ($libXmlErrors as $error) {
            $errors[] = "{$error->message} Line: {$error->line}";
        }
        $this->logger->info(
            sprintf("Theme layout update file '%s' is not valid.\n%s", $fileName, implode("\n", $errors))
        );
    }
}

and then continues with system execution.

Requested Behavior: When developer mode is enabled, this should be a "hard crash" instead (throwing an exception?). i.e. If a developer's working on their system with developer mode on, and they make a mistake in a layout handle configuration file, the system should halt execution and tell at them about their bad XML.

This would match Magento 1.x behavior, as well as follow the general "fail fast" principle exposed in certain corners of the software development world.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions