-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exception tests with new error object
- Loading branch information
Showing
6 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41a7a20
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 this is the wrong fix. I encountered this issue myself and fixed it locally, but my fix ensures the one inviolate contract, your API interface, is not changed. In short, you can rename
getError()
togetFullError()
orgetErrorObject()
(or something of that ilk), and renamegetErrorMessage()
back togetError()
— then you don't need to change ResponseException.php, and everybody using the Elastica\Response class won't have to update their code. I do think though that if I were starting from scratch, getError() and getErrorMessage() would be the right names for these methods. Please don't break existing code when there is another way. Also, I don't believe you should be returning an empty array if there is no error in the response data. Returnnull
as this will indicate that there is no error, rather than an error with no information (as implied by the empty array). Finally, line 93 needs a new line before the opening brace.41a7a20
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.
FWIW here's what I did (it met my need of finding out the index name for the exception I was having, and uses the early-return paradigm to avoid nesting):
41a7a20
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.
@nickshanks I like this change. The above was more a "fast fix" to get it working. Any chance you could open a PR with your changes? @ewgRa What do you think?
41a7a20
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 don't know background of this changes so I can't say something valued. From code perspective @nickshanks fix looks reasonable and haven't BC.
Maybe there is a reason rename getFullError to getRawError, to show that this is an error that ES return.
41a7a20
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 opened #1016 as I would like to get this change into beta2
41a7a20
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.
@nickshanks Can you have a look at #1016 and let me know if that is as expected for you? I took your code, made some small changes and fixed the tests.
41a7a20
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.
@ruflin Happy new year. I'm taking a look now…
41a7a20
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.
Yeah, I see no problems. Have commented on a couple of style niggles but I'm not sure what your coding style guidelines are.