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

Exception: increase verbosity with imap_alerts() and imap_errors() #182

Merged
merged 3 commits into from
Sep 26, 2017

Conversation

Slamdunk
Copy link
Collaborator

Call imap_alerts() and imap_errors() while building Exception message to increase verbosity and raise awareness of what happened.

Before:

Authentication failed for user "fake_username_59c9f91cc66e6": imap_open():
Couldn't open stream {my.server.com:60993/imap/ssl/validate-cert}

After:

[E_WARNING] Authentication failed for user "fake_username_59c9f91cc66e6": imap_open():
Couldn't open stream {my.server.com:60993/imap/ssl/validate-cert}
imap_alerts (0):
imap_errors (1):
- Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed.

@Slamdunk Slamdunk added this to the 1.0 milestone Sep 26, 2017

public function __construct($message, $code = 0, $previous = null)
final public function __construct($message, $code = 0, $previous = null)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't repeat yourself: with final keyword we ensure every Exception in this library follows this pattern

@Slamdunk
Copy link
Collaborator Author

As you can see in Travis in the first build of this PR:
https://travis-ci.org/ddeboer/imap/jobs/279831280#L722-L726

1) Ddeboer\Imap\Tests\ServerTest::testFailedAuthenticate
Failed asserting that exception message '[E_WARNING] Authentication failed for user "fake_username_59c9fb455ebfb": imap_open(): Couldn't open stream {dovecot.travis.dev:993/imap/ssl/validate-cert}
imap_alerts (0):
imap_errors (1):
- Certificate failure for dovecot.travis.dev: self signed certificate: /C=EU/ST=Europe/L=Home/O=Travis/OU=Travis DEV/CN=dovecot.travis.dev' matches '/E_WARNING.+AUTHENTICATIONFAILED/s'.

It is far easier to detect the real error now.

@Slamdunk Slamdunk merged commit 4763f3b into ddeboer:develop Sep 26, 2017
@Slamdunk Slamdunk deleted the exception_details branch September 26, 2017 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant