diff --git a/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java b/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
index 2af7761b62851fc049fcee5ef9c8f71dbdff5cad..d9bc3ab0bb8014b74686b9dd5826a12facd31a16 100644
--- a/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
+++ b/commons/src/main/java/lcsb/mapviewer/common/geometry/ColorParser.java
@@ -47,6 +47,10 @@ public class ColorParser {
    * @return {@link Color} obtained from input text
    */
   public Color parse(String string) {
+    if (string==null || string.isEmpty()) {
+      throw new InvalidArgumentException(
+          "Invalid color value: " + string + ". Correct format: #xxxxxx (where x is a hex value)");
+    }
     if (string.charAt(0) != '#') {
       string = "#" + string;
     }
diff --git a/commons/src/test/java/lcsb/mapviewer/common/geometry/ColorParserTest.java b/commons/src/test/java/lcsb/mapviewer/common/geometry/ColorParserTest.java
index 710cfa15116f68a3a2373e47e387a702a6b41dd3..4b927108fbb9285709a30cc13d0643cd5bd45be5 100644
--- a/commons/src/test/java/lcsb/mapviewer/common/geometry/ColorParserTest.java
+++ b/commons/src/test/java/lcsb/mapviewer/common/geometry/ColorParserTest.java
@@ -64,6 +64,18 @@ public class ColorParserTest {
     }
   }
 
+  @Test(expected=InvalidArgumentException.class)
+  public void testParseNull() throws Exception {
+      ColorParser parser = new ColorParser();
+      parser.parse(null);
+  }
+
+  @Test(expected=InvalidArgumentException.class)
+  public void testParseEmpty() throws Exception {
+      ColorParser parser = new ColorParser();
+      parser.parse("");
+  }
+
   @Test
   public void testSetColorToHtmlString() throws Exception {
     try {