Always throw a descriptive exception instead of returning nothing.
[shibboleth/opensaml2.git] / saml / saml2 / binding / impl / SAML2POSTDecoder.cpp
index 692950b..988aa0f 100644 (file)
@@ -76,17 +76,15 @@ XMLObject* SAML2POSTDecoder::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(),"POST"))
-        return NULL;
+        throw BindingException("Invalid HTTP method ($1).", params(1, httpRequest->getMethod()));
     const char* msg = httpRequest->getParameter("SAMLResponse");
     if (!msg)
         msg = httpRequest->getParameter("SAMLRequest");
     if (!msg)
-        return NULL;
+        throw BindingException("Request missing SAMLRequest or SAMLResponse parameter.");
     const char* state = httpRequest->getParameter("RelayState");
     if (state)
         relayState = state;