-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: master
Are you sure you want to change the base?
Conversation
if (preg_match('/.*\[\]$/', $className)) { | ||
$className = substr($className, 0, -2); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
if (null === $errorClass) { | ||
return $endpoint; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
No description provided.