diff --git a/dictionaries/errors.definition.json b/dictionaries/errors.definition.json
index f2b9261f1e31baab9c2d818a4ebb5cc2b2c6e083..b2d6cfb4b670b0f3861d4012852e1cf0a035daf8 100644
--- a/dictionaries/errors.definition.json
+++ b/dictionaries/errors.definition.json
@@ -205,5 +205,11 @@
 	},
 	"descr_NOSTATE": {
 		"en": "State information lost, and no way to restart the request"
+	},
+	"title_METADATANOTFOUND": {
+		"en": "Metadata not found"
+	},
+	"descr_METADATANOTFOUND": {
+		"en": "Unable to locate metadata for %ENTITYID%"
 	}
 }
diff --git a/lib/SimpleSAML/Error/MetadataNotFound.php b/lib/SimpleSAML/Error/MetadataNotFound.php
index d079331fbf8d7e1a417cbcb325fd8a66d94ca324..fb2d483237ae2cbe8f67a1d59d4c4a061ac63d8a 100644
--- a/lib/SimpleSAML/Error/MetadataNotFound.php
+++ b/lib/SimpleSAML/Error/MetadataNotFound.php
@@ -24,7 +24,11 @@ class SimpleSAML_Error_MetadataNotFound extends SimpleSAML_Error_Error {
 	public function __construct($entityId) {
 		assert('is_string($entityId)');
 
-		parent::__construct('Unable to locate metadata for ' . var_export($entityId, TRUE) . '.');
+		parent::__construct(array(
+				'METADATANOTFOUND',
+				'ENTITYID' => htmlspecialchars(var_export($entityId, TRUE))
+		));
+
 		$this->entityId = $entityId;
 	}