Browse Source

Log the source of the failure when an aliased script fails, fixes #7201

Jordi Boggiano 7 years ago
parent
commit
288631a37e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/Composer/EventDispatcher/EventDispatcher.php

+ 6 - 1
src/Composer/EventDispatcher/EventDispatcher.php

@@ -186,7 +186,12 @@ class EventDispatcher
                         $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
                     }
 
-                    $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
+                    try {
+                        $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
+                    } catch (ScriptExecutionException $e) {
+                        $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
+                        throw $e;
+                    }
                 }
             } elseif ($this->isPhpScript($callable)) {
                 $className = substr($callable, 0, strpos($callable, '::'));