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 handling custom error class #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

piotrpasich
Copy link

No description provided.

Service/Endpoint/Endpoint.php Outdated Show resolved Hide resolved
Service/Endpoint/EndpointFactory.php Show resolved Hide resolved
Comment on lines +164 to +166
if (preg_match('/.*\[\]$/', $className)) {
$className = substr($className, 0, -2);
}

Choose a reason for hiding this comment

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

Is it needed? Seems to be checking if the $className ends with a [], which won't be a case here - yet it was supported for response classes.

Copy link
Author

Choose a reason for hiding this comment

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

I think it was introduced to avoid a situation when the configuration is put as an array in YML. I would leave it as it is to keep the things the same

Service/Endpoint/EndpointImmutable.php Outdated Show resolved Hide resolved
Service/Endpoint/EndpointImmutable.php Show resolved Hide resolved
Comment on lines +159 to +160
if (null === $errorClass) {
return $endpoint;

Choose a reason for hiding this comment

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

Wouldn't it be easier to always have an $errorClass ? So that a default would be defined as well for generic purposes/existing implementations?

Copy link
Author

Choose a reason for hiding this comment

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

Error class like other classes are in the ServiceAPIClientBundle repository. I'm worried about circular dependency.

Copy link
Author

Choose a reason for hiding this comment

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

Error class like other classes are in the ServiceAPIClientBundle repository. I'm worried about circular dependency. Let's keep it that way

@@ -58,6 +63,7 @@ class EndpointImmutable implements EndpointInterface
* @param string $responseFormat
* @param null|string $responseClass
* @param null|string $dateTimeFormat
* @param null|string $errorClass

Choose a reason for hiding this comment

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

Doc and constructor doesn't match.

Copy link
Contributor

@Dropaq Dropaq left a comment

Choose a reason for hiding this comment

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

general things about implementation:

  • easy part: as mentioned, please introduce errorFormat in alignment with responseFormat (json by default but overridable)

  • less easy part: response returns either particular entity or collection of them
    errors aren't so straightforward
    would love to see the configurable collection of objects here with error codes as key
    because in most cases responses would be smth like:

    • 400\409: validation error collection
    • 401\403\404 - dummy body
    • 500: some less dummy body, maybe

    please think it through

Service/Endpoint/Endpoint.php Outdated Show resolved Hide resolved
Service/Endpoint/EndpointFactory.php Show resolved Hide resolved
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.

4 participants