diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index 08e5c48f8ede1ce47e1588bb2a535631a69f8f9c..f87fee50bb7bd1d5f3aad5c370a59b8a70f2bf72 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -105,7 +105,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 		assert('is_string($entityId)');
 
 		if ($this->idp !== NULL && $this->idp !== $entityId) {
-			throw new SimpleSAML_Error_Exception('Cannot retrieve metadata for IdP ' . var_export($this->idp, TRUE) .
+			throw new SimpleSAML_Error_Exception('Cannot retrieve metadata for IdP ' . var_export($entityId, TRUE) .
 				' because it isn\'t a valid IdP for this SP.');
 		}