diff --git a/modules/saml2/www/sp/acs.php b/modules/saml2/www/sp/acs.php
index 929257e5fa916bde36580b8b42a41cebc20c7c09..57d26db67967b16bb2393268caacfdb2cca81b65 100644
--- a/modules/saml2/www/sp/acs.php
+++ b/modules/saml2/www/sp/acs.php
@@ -34,8 +34,7 @@ $result = $authnResponse->process();
 /* Check status code. */
 if($result === FALSE) {
 	/* Not successful. */
-	$statusCode = $authnResponse->findstatus();
-	throw new Exception('Error authenticating: ' . $statusCode);
+	SimpleSAML_Auth_State::throwException($state, $authnResponse->getStatus()->toException());
 }
 
 /* The response should include the entity id of the IdP. */