diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 5ca5f26..62b061f 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -10,6 +10,8 @@
 use Drupal\Core\Asset\Exception\IncompleteLibraryDefinitionException;
 use Drupal\Core\Asset\Exception\InvalidLibraryFileException;
 use Drupal\Core\Asset\Exception\LibraryDefinitionMissingLicenseException;
+use Drupal\Core\Asset\Exception\InvalidDefinationOfCssException;
+use Drupal\Core\Asset\Exception\InvalidCssCategoryException;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
 use Drupal\Component\Serialization\Yaml;
@@ -118,12 +120,21 @@ public function buildByExtension($extension) {
         //   and only once prior to rendering out an HTML page.
         if ($type == 'css' && !empty($library[$type])) {
           foreach ($library[$type] as $category => $files) {
+            if (empty($files)) {
+              throw new InvalidDefinationOfCssException(sprintf("You have to key the css files in the '%s'.library.yml file by category ('%s' seems to be a file name, allowed categories are Base, Layout, Component, State, Theme)", $extension, $category));
+            }
             foreach ($files as $source => $options) {
               if (!isset($options['weight'])) {
                 $options['weight'] = 0;
               }
-              // Apply the corresponding weight defined by CSS_* constants.
-              $options['weight'] += constant('CSS_' . strtoupper($category));
+              //Check if the category is valid or not and
+              // apply the corresponding weight defined by CSS_* constants.
+              if (defined('CSS_' . strtoupper($category))) {
+                $options['weight'] += constant('CSS_' . strtoupper($category));
+              }
+              else {
+                throw new InvalidCssCategoryException(sprintf("You have used an invalid category %s in %s.libraries.yml. Allowed categories are Base, Layout, Component, State, Theme)", $category, $extension));
+              }
               $library[$type][$source] = $options;
             }
             unset($library[$type][$category]);
diff --git a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php
index 00c613d..3b5841e 100644
--- a/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php
+++ b/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php
@@ -52,6 +52,7 @@ public function __construct($offset = 0)
      */
     public function parse($value, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
     {
+        
         $this->currentLineNb = -1;
         $this->currentLine = '';
         $this->lines = explode("\n", $this->cleanup($value));
