diff --git a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
index 53c33d9..8ec6428 100644
--- a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
+++ b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php
@@ -80,7 +80,15 @@ protected function createService(array $definition, $id) {
         throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id));
       }
 
-      $service = call_user_func_array($factory, $arguments);
+      // call_user_func_array() makes it appear that exceptions that occur in
+      // the called functions have occurred where call_user_func_array() was
+      // called. Instead, rethrow an exception to get a better call stack.
+      try {
+        $service = call_user_func_array($factory, $arguments);
+      }
+      catch (\Exception $e) {
+        throw new \Exception($e);
+      }
     }
     else {
       $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class'])));
