diff --git a/core/Container/ContainerDoesNotExistException.php b/core/Container/ContainerDoesNotExistException.php
new file mode 100644
index 0000000000000000000000000000000000000000..9577d51624548790ba7324aa2d65d272dfa091bd
--- /dev/null
+++ b/core/Container/ContainerDoesNotExistException.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik\Container;
+
+use RuntimeException;
+
+/**
+ * Thrown if the root container has not been created and set in StaticContainer.
+ */
+class ContainerDoesNotExistException extends RuntimeException
+{
+}
\ No newline at end of file
diff --git a/core/Container/StaticContainer.php b/core/Container/StaticContainer.php
index 09fd5f552ef47c02aed8a458ca0839fb0a9661b6..fca87c04b71fbcb9d48ae21ae61f624db1f5ea38 100644
--- a/core/Container/StaticContainer.php
+++ b/core/Container/StaticContainer.php
@@ -37,7 +37,7 @@ class StaticContainer
     public static function getContainer()
     {
         if (self::$container === null) {
-            throw new \Exception("The root container has not been created yet.");
+            throw new ContainerDoesNotExistException("The root container has not been created yet.");
         }
 
         return self::$container;
diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php
index 5b02cd77f6a706bdf58deb6b2530be128e3dd6f7..ac61707a29bca45d82d1851038111216485852a6 100644
--- a/core/ExceptionHandler.php
+++ b/core/ExceptionHandler.php
@@ -9,6 +9,7 @@
 namespace Piwik;
 
 use Exception;
+use Piwik\Container\ContainerDoesNotExistException;
 use Piwik\Plugins\CoreAdminHome\CustomLogo;
 
 /**
@@ -87,16 +88,20 @@ class ExceptionHandler
 
         $result = Piwik_GetErrorMessagePage($message, $debugTrace, true, true, $logoHeaderUrl, $logoFaviconUrl);
 
-        /**
-         * Triggered before a Piwik error page is displayed to the user.
-         *
-         * This event can be used to modify the content of the error page that is displayed when
-         * an exception is caught.
-         *
-         * @param string &$result The HTML of the error page.
-         * @param Exception $ex The Exception displayed in the error page.
-         */
-        Piwik::postEvent('FrontController.modifyErrorPage', array(&$result, $ex));
+        try {
+            /**
+             * Triggered before a Piwik error page is displayed to the user.
+             *
+             * This event can be used to modify the content of the error page that is displayed when
+             * an exception is caught.
+             *
+             * @param string &$result The HTML of the error page.
+             * @param Exception $ex The Exception displayed in the error page.
+             */
+            Piwik::postEvent('FrontController.modifyErrorPage', array(&$result, $ex));
+        } catch (ContainerDoesNotExistException $ex) {
+            // this can happen when an error occurs before the Piwik environment is created
+        }
 
         return $result;
     }