diff --git a/www/admin/metadata.php b/www/admin/metadata.php
index d9d30025fae9e72e5efbbf69f0ce01b9f1db6d40..1217f40a4124d031024fa5b71f110295d7841ff8 100644
--- a/www/admin/metadata.php
+++ b/www/admin/metadata.php
@@ -9,7 +9,7 @@ require_once('SimpleSAML/XHTML/Template.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getInstance(true);
 
 
 /* Check if valid local session exists.. */
@@ -131,13 +131,7 @@ try {
 	$et->show();
 	
 } catch(Exception $exception) {
-	
-	$et = new SimpleSAML_XHTML_Template($config, 'error.php');
-
-	$et->data['message'] = 'Some error occured when trying to generate metadata.';	
-	$et->data['e'] = $exception;
-	
-	$et->show();
+	SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception);
 
 }
 
diff --git a/www/saml2/sp/metadata.php b/www/saml2/sp/metadata.php
index 8e0ed035b7c5bda6cbcde672d0e35c20cafb5e72..9ff76a86f5ed8e04c6fb60a39716c431457d55c1 100644
--- a/www/saml2/sp/metadata.php
+++ b/www/saml2/sp/metadata.php
@@ -85,12 +85,7 @@ try {
 	
 } catch(Exception $exception) {
 	
-	$et = new SimpleSAML_XHTML_Template($config, 'error.php');
-
-	$et->data['message'] = 'Some error occured when trying to generate metadata.';	
-	$et->data['e'] = $exception;
-	
-	$et->show();
+	SimpleSAML_Utilities::fatalError($session->getTrackID(), 'METADATA', $exception);
 
 }