Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add own exceptions to the library #37

Open
jaimeperez opened this issue Mar 19, 2015 · 6 comments
Open

Add own exceptions to the library #37

jaimeperez opened this issue Mar 19, 2015 · 6 comments

Comments

@jaimeperez
Copy link
Member

jaimeperez commented Mar 19, 2015

While trying to add more meaningful messages to some of the typical errors, I've noticed that at some points in the library we are throwing simple exceptions with a message that's not really descriptive of the real problem, nor even translated. For instance, in \SAML2\SOAP::receive():

        $postText = file_get_contents('php://input');

        if (empty($postText)) {
            throw new Exception('Invalid message received to AssertionConsumerService endpoint.');
        }

or in \SAML2\Binding::getCurrentBinding():

        throw new Exception('Unable to find the current binding.');

If these were custom exceptions, we could capture them easily and display a meaningful, translated error message to the user, depending on where we are. Therefore I think we should even move some of the exceptions in SimpleSAMLphp to this library, and extend them with specific ones.

@relaxnow
Copy link
Contributor

Good point!

@jaimeperez
Copy link
Member Author

If only I could find time to do all the stuff I need to do... 😢

@salvorapi
Copy link

+1

@tvdijen
Copy link
Member

tvdijen commented Jan 16, 2022

Much work has been done.. Some left;

grep -R "throw new Exception" * --exclude-dir=vendor

@tvdijen

This comment was marked as outdated.

@tvdijen
Copy link
Member

tvdijen commented Mar 14, 2023

Update:

src/SAML2/Response/Validation/ConstraintValidator/DestinationMatches.php:            throw new Exception('No destination set in the response.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Unable to send artifact without a datastore configured.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Cannot get redirect URL, no Issuer set in the message.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Cannot get redirect URL, no destination set in the message.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Missing SAMLart parameter.');
src/SAML2/HTTPArtifact.php:            throw new Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, true));
src/SAML2/HTTPArtifact.php:            throw new Exception('No ArtifactResolutionService with the correct index.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Received error from ArtifactResolutionService.');
src/SAML2/HTTPArtifact.php:            throw new Exception('Empty ArtifactResponse received, maybe a replay?');
src/SAML2/HTTPPost.php:                throw new Exception('Cannot send message, no destination set.');
src/SAML2/HTTPPost.php:            throw new Exception('Missing SAMLRequest or SAMLResponse parameter.');
src/SAML2/HTTPRedirect.php:                throw new Exception('Cannot build a redirect URL, no destination set.');
src/SAML2/HTTPRedirect.php:            throw new Exception('Missing SAMLRequest or SAMLResponse parameter.');
src/SAML2/HTTPRedirect.php:            throw new Exception(sprintf('Unknown SAMLEncoding: %s', $query['SAMLEncoding']));
src/SAML2/HTTPRedirect.php:            throw new Exception('Error while base64 decoding SAML message.');
src/SAML2/HTTPRedirect.php:            throw new Exception('Error while inflating SAML message.');
src/SAML2/HTTPRedirect.php:            throw new Exception('Missing signature algorithm.');
src/SAML2/SOAP.php:                throw new Exception('No destination available for SOAP message.');
src/SAML2/SOAPClient.php:            throw new Exception('Cannot send SOAP message, no destination set.');
src/SAML2/SOAPClient.php:            throw new Exception('Empty SOAP response, check peer certificate.');
src/SAML2/SOAPClient.php:            throw new Exception(
src/SAML2/SOAPClient.php:            throw new Exception('Unable to get key details from XMLSecurityKey.');
src/SAML2/SOAPClient.php:            throw new Exception('Missing key in public key details.');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Release 5.0
  
Awaiting triage
Development

No branches or pull requests

4 participants