diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index dc5fb0a..3967cf8 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -99,8 +99,9 @@ protected function createAttributeValue($name, $value) { elseif (!is_object($value)) { $value = new AttributeString($name, $value); } - elseif (is_object($value) && !($value instanceof AttributeValueBase) && !method_exists($value, '__toString')) { - throw new Exception(t('"@attribute_name" attribute value of type "@class" can not be converted to string', array( + // Provide a better exception message when invalid object is passed as value. + elseif (is_object($value) && !method_exists($value, '__toString')) { + throw new \Exception(t('"@attribute_name" attribute value of type "@class" can not be converted to string', array( '@attribute_name' => $name, '@class' => get_class($value) )));