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

Better handling of bad responses, Response class started, tests added #140

Merged
merged 3 commits into from
Nov 20, 2017

Conversation

escopecz
Copy link
Member

This PR moves the HTML response responsibility from AbstractAuth to new Response class. It improves testability and the tests are part of this PR.

This PR also slightly changes the behavior. I don't consider it a BC break but bug fix.

  • If the response is in bad format like HTML the UnexpectedResponseFormatException is thrown. This exception was previously thrown only if HTTP code was not 200 or 201.
  • The UnexpectedResponseFormatException has first new param and that is the new Response class so it could build a more detailed error message out of it. That can be considered to be BC, but exceptions from this library should not be thrown in code outside of this library.

lib/Response.php Outdated
$parsed = $this->decodeFromJson();
} catch (UnexpectedResponseFormatException $e) {
$parsed = $this->decodeFromUrlParams();
die(var_dump($parsed));
Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this is debug code.


if (empty($message)) {
// Use message appropriate to the subclass with late binding
$message = static::DEFAULT_MESSAGE;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be self? Don't see a need for late static bindings here.

@alanhartless alanhartless merged commit db69aaf into mautic:master Nov 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants