diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php
index e123b4a..477eb54 100644
--- a/core/lib/Drupal/Component/Utility/NestedArray.php
+++ b/core/lib/Drupal/Component/Utility/NestedArray.php
@@ -143,7 +143,7 @@ public static function &getValue(array &$array, array $parents, &$key_exists = N
    * @param bool $force
    *   (optional) If TRUE, the value is forced into the structure even if it
    *   requires the deletion of an already existing non-array parent value. If
-   *   FALSE, PHP throws an error if trying to add into a value that is not an
+   *   FALSE, throw an Exception if trying to add into a value that is not an
    *   array. Defaults to FALSE.
    *
    * @see NestedArray::unsetValue()
@@ -154,8 +154,14 @@ public static function setValue(array &$array, array $parents, $value, $force =
     foreach ($parents as $parent) {
       // PHP auto-creates container arrays and NULL entries without error if $ref
       // is NULL, but throws an error if $ref is set, but not an array.
-      if ($force && isset($ref) && !is_array($ref)) {
-        $ref = array();
+      if (isset($ref) && !is_array($ref)) {
+        if ($force) {
+          $ref = array();
+        }
+        else {
+          // Throw an Exception if $ref is set, but not an array.
+          throw new \Exception('Scalar value cannot be used as array.');
+        }
       }
       $ref = &$ref[$parent];
     }
diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php
index 552eacf..c8b2ebd 100644
--- a/core/lib/Drupal/Core/Config/ConfigBase.php
+++ b/core/lib/Drupal/Core/Config/ConfigBase.php
@@ -183,6 +183,7 @@ public function setData(array $data) {
    *
    * @throws \Drupal\Core\Config\ConfigValueException
    *   If $value is an array and any of its keys in any depth contains a dot.
+   *   If an existing scalar value is treated as an array when $key contains a dot.
    */
   public function set($key, $value) {
     // The dot/period is a reserved character; it may appear between keys, but
@@ -195,7 +196,14 @@ public function set($key, $value) {
       $this->data[$key] = $value;
     }
     else {
-      NestedArray::setValue($this->data, $parts, $value);
+      try {
+        NestedArray::setValue($this->data, $parts, $value);
+      } catch (\Exception $e) {
+        throw new ConfigValueException(String::format('Could not set @key. @message', array(
+          '@key' => $key,
+          '@message' => $e->getMessage()
+        )));
+      }
     }
     return $this;
   }
diff --git a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
index 4111e08..1a9b65e 100644
--- a/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
+++ b/core/tests/Drupal/Tests/Core/Config/ConfigTest.php
@@ -206,9 +206,12 @@ public function testSetValidation() {
 
   /**
    * @covers ::set
-   * @expectedException PHPUnit_Framework_Error_Warning
+   * @expectedException \Drupal\Core\Config\ConfigValueException
    */
   public function testSetIllegalOffsetValue() {
+    // Set expected exception.
+    $this->setExpectedException('\Drupal\Core\Config\ConfigValueException', 'Could not set testData.illegalOffset. Scalar value cannot be used as array.');
+
     // Set a single value.
     $this->config->set('testData', 1);
 
