diff --git a/lib/SAML2/HTTPArtifact.php b/lib/SAML2/HTTPArtifact.php
index f049272ccaa164d0b461d97069cd638e1f119d89..d57274212137b3fbdeadef73990078c095221422 100644
--- a/lib/SAML2/HTTPArtifact.php
+++ b/lib/SAML2/HTTPArtifact.php
@@ -80,6 +80,9 @@ class SAML2_HTTPArtifact extends SAML2_Binding {
 
 		$idpmetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote');
 
+		if ($idpmetadata === NULL) {
+			throw new Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, TRUE));
+		}
 
 		$endpoint = NULL;
 		foreach ($idpmetadata->getEndpoints('ArtifactResolutionService') as $ep) {