   MD: 'urn:oasis:names:tc:SAML:2.0:metadata'
   DS: 'http://www.w3.org/2000/09/xmldsig#'
   XENC: 'http://www.w3.org/2001/04/xmlenc#'
+
+class SAMLError extends Error
+  constructor: (@message, @extra) ->
+    super @message
 
 # Creates an AuthnRequest and returns it as a string of xml along with the randomly generated ID for the created
 # request.

      for attr in status_code.attributes
        return true if attr.name is 'Value' and attr.value is 'urn:oasis:names:tc:SAML:2.0:status:Success'
  false

to_error = (err) ->
  return null unless err?

          response = { response_header }
          switch
            when saml_response.getElementsByTagNameNS(XMLNS.SAMLP, 'Response').length is 1
              unless check_status_success(saml_response)
                cb_wf new SAMLError("SAML Response was not success!", { status: get_status(saml_response) })
              response.type = 'authn_response'
              parse_authn_response saml_response, @private_key, identity_provider.certificates, cb_wf
            when saml_response.getElementsByTagNameNS(XMLNS.SAMLP, 'LogoutResponse').length is 1
              unless check_status_success(saml_response)
                cb_wf new SAMLError("SAML Response was not success!", { status: get_status(saml_response) })
              response.type = 'logout_response'
              setImmediate cb_wf, null, {}
            when saml_response.getElementsByTagNameNS(XMLNS.SAMLP, 'LogoutRequest').length is 1
