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 response id to request error. (bunq/sdk_php#88) #93

Merged

Conversation

OGKevin
Copy link
Contributor

@OGKevin OGKevin commented Dec 26, 2017

Closes #88

  • Tested

@OGKevin OGKevin added this to the 0.12.5 milestone Dec 26, 2017
@OGKevin
Copy link
Contributor Author

OGKevin commented Dec 27, 2017

@sandervdo please 👀

@bunq bunq deleted a comment Dec 27, 2017
Copy link
Contributor

@sandervdo sandervdo left a comment

Choose a reason for hiding this comment

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

@OGKevin all yours. 😄

{
private static function generateErrorMessage(
int $responseCode,
array $messages,
Copy link
Contributor

Choose a reason for hiding this comment

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

allMessage

{
$errorMessage = static::generateErrorMessage($responseCode, $messages);
public static function createExceptionForResponse(
array $messages,
Copy link
Contributor

Choose a reason for hiding this comment

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

allMessage

@@ -20,6 +20,8 @@ class ExceptionFactory
* Formatting constants
*/
const FORMAT_RESPONSE_CODE_LINE = 'HTTP Response Code: %s';
const FORMAT_RESPONSE_ID = 'The response id to help bunq debug: %s';
const FORMAT_ERROR_MESSAGE_LINE = 'Error message: %s';
const GLUE_ERROR_MESSAGES = "\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

ERROR_MESSAGE_GLUE? ERROR_MESSAGE_SEPARATOR might even be better

* The index of the first item in an array.
*/
const INDEX_FIRST = 0;

/**
* @param ResponseInterface $response
*
Copy link
Contributor

Choose a reason for hiding this comment

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

@return

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Invalid, as you can see this particular line has not been changed in this pr and therefore only a snippet of the doc block is show. If you look at the original file you see that this doc block is correct 🙃 see:

* @return ResponseInterface

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, missed that one. Ignore then. 😄

@@ -65,11 +80,32 @@ private function fetchErrorDescriptions(array $errorArray): array
{
$errorDescriptions = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

allErrorDescription

@@ -49,9 +64,9 @@ private function fetchErrorMessages(ResponseInterface $response): array
$responseBody = $response->getBody();
$responseBodyInJson = json_decode($responseBody, true);

if ($responseBodyInJson !== false){
if ($responseBodyInJson !== false) {
return $this->fetchErrorDescriptions($responseBodyInJson);
Copy link
Contributor

Choose a reason for hiding this comment

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

fetchAllErrorDescription

@@ -0,0 +1,29 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

*/
public function testBadRequestWitResponseId()
{
$caughtExcretion = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean exception?

$caughtExcretion = null;

try {
UserPerson::get(static::$apiContext, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Magic number

@bunq bunq deleted a comment Dec 27, 2017
@OGKevin
Copy link
Contributor Author

OGKevin commented Dec 27, 2017

@sandervdo all yours again, please 👀

Copy link
Contributor

@sandervdo sandervdo left a comment

Choose a reason for hiding this comment

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

@OGKevin done. 1 more plural I noticed and see comment on the naming of your constant (might be a SDK specific thing) :)


return static::glueMessages(array_merge([$lineResponseCode], $messages));
return static::glueMessages([$lineResponseCode, $lineResponseId, $lineErrorMessage]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh crap, I see a plural here now too. 🙈

@@ -78,6 +96,6 @@ private static function generateErrorMessage(int $responseCode, array $messages)
*/
private static function glueMessages(array $messages): string
{
return implode(self::GLUE_ERROR_MESSAGES, $messages);
return implode(self::SEPARATOR_ERROR_MESSAGES, $messages);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would call it ERROR_MESSAGE_SEPARATOR then, (big -> small)

Copy link
Contributor Author

@OGKevin OGKevin Dec 27, 2017

Choose a reason for hiding this comment

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

We normally group constants together, so in this case this constant belongs to the SEPARATOR_ constant group. As you can have multiple separators and then the constant names will begin with SEPARATOR_XXXXXX.

@bunq bunq deleted a comment Dec 27, 2017
@OGKevin
Copy link
Contributor Author

OGKevin commented Dec 27, 2017

@sandervdo all yours again, please 👀

sandervdo
sandervdo previously approved these changes Dec 27, 2017
@OGKevin OGKevin assigned andrederoos and OGKevin and unassigned OGKevin and sandervdo Dec 27, 2017
@OGKevin
Copy link
Contributor Author

OGKevin commented Dec 27, 2017

@andrederoos All yours.

@bunq bunq deleted a comment Dec 27, 2017
@bunq bunq deleted a comment Dec 30, 2017
@OGKevin OGKevin changed the title Feature/bunq/sdk php#88 add response id to request error Add response id to request error. (bunq/sdk_php#88) Dec 30, 2017
@andrederoos
Copy link
Contributor

@OGKevin branche is out-of-date

@OGKevin OGKevin force-pushed the feature/bunq/sdk_php#88-add_response_id_to_request_error branch from 7b09710 to 3653cf3 Compare January 2, 2018 09:31
@OGKevin
Copy link
Contributor Author

OGKevin commented Jan 2, 2018

@andrederoos my bad, updated 🤦‍♂️

@bunq bunq deleted a comment Jan 2, 2018
@bunq bunq deleted a comment Jan 2, 2018
@andrederoos andrederoos merged commit 4b645d6 into develop Jan 2, 2018
@andrederoos andrederoos deleted the feature/bunq/sdk_php#88-add_response_id_to_request_error branch January 2, 2018 20:38
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.

3 participants