diff --git a/html/geticon.php b/html/geticon.php
index f66c32d2f7704ce94512e58bb397f1eff26cad9c..df0c5aa5fa31ec84d64abec569a74309fb07d7c4 100644
--- a/html/geticon.php
+++ b/html/geticon.php
@@ -1,7 +1,7 @@
 <?php
 /*
   This code is part of FusionDirectory (http://www.fusiondirectory.org/)
-  Copyright (C) 2013-2016  FusionDirectory
+  Copyright (C) 2013-2020  FusionDirectory
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -39,7 +39,11 @@ if (!isset($_GET['context']) || !isset($_GET['icon']) || !isset($_GET['size']))
   trigger_error('Missing information in query string: '.$_SERVER['QUERY_STRING']);
   exit;
 }
-$src    = IconTheme::findThemeIcon($theme, $_GET['context'], $_GET['icon'], $_GET['size']);
+$src  = IconTheme::findThemeIcon($theme, $_GET['context'], $_GET['icon'], $_GET['size']);
+if ($src === NULL) {
+  trigger_error('Could not find icon for '.$_SERVER['QUERY_STRING']);
+  exit;
+}
 
 header("Content-Type: image/png");
 if (isset($_GET['disabled']) && $_GET['disabled']) {
diff --git a/include/class_IconTheme.inc b/include/class_IconTheme.inc
index 84023218e5ecac10fbaacd191e76956bafd82ed1..f271cd755fbed483dd483b63022ecd530df7dd77 100644
--- a/include/class_IconTheme.inc
+++ b/include/class_IconTheme.inc
@@ -227,6 +227,7 @@ class IconTheme
   static public function findThemeIcon ($theme, $context, $icon, $size)
   {
     if (!isset($_SESSION[static::$session_var])) {
+      trigger_error('Error: no theme found in session');
       die('Error: no theme found in session');
     }
     if (isset($_SESSION[static::$session_var][$theme])) {