diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php
index 914b6b687119c64a6c5e6c22159fea4037a424e7..6a51c1e6c904f65cb6324e7cfa009270c3d63ee1 100644
--- a/lib/SimpleSAML/Store.php
+++ b/lib/SimpleSAML/Store.php
@@ -50,7 +50,17 @@ abstract class SimpleSAML_Store
                 break;
             default:
                 // datastore from module
-                $className = SimpleSAML\Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
+                try {
+                    $className = SimpleSAML\Module::resolveClass($storeType, 'Store', 'SimpleSAML_Store');
+                } catch (Exception $e) {
+                    $c = $config->toArray();
+                    $c['store.type'] = 'phpsession';
+                    throw new SimpleSAML\Error\CriticalConfigurationError(
+                        "Invalid 'store.type' configuration option. Cannot find store '$storeType'.",
+                        null,
+                        $c
+                    );
+                }
                 self::$instance = new $className();
         }