Always throw a descriptive exception instead of returning nothing.
[shibboleth/opensaml2.git] / saml / saml1 / binding / impl / SAML1ArtifactDecoder.cpp
index 3a5fbbf..ee5278a 100644 (file)
@@ -75,16 +75,14 @@ XMLObject* SAML1ArtifactDecoder::decode(
 
     log.debug("validating input");
     const HTTPRequest* httpRequest=dynamic_cast<const HTTPRequest*>(&genericRequest);
-    if (!httpRequest) {
-        log.error("unable to cast request to HTTPRequest type");
-        return NULL;
-    }
+    if (!httpRequest)
+        throw BindingException("Unable to cast request object to HTTPRequest type.");
     if (strcmp(httpRequest->getMethod(),"GET"))
-        return NULL;
+        throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
     vector<const char*> SAMLart;
     const char* TARGET = httpRequest->getParameter("TARGET");
     if (httpRequest->getParameters("SAMLart", SAMLart)==0 || !TARGET)
-        return NULL;
+        throw BindingException("Request missing SAMLart or TARGET parameters.");
     relayState = TARGET;
 
     if (!m_artifactResolver || !policy.getMetadataProvider() || !policy.getRole())