Skip to content

Conversation

@saghm
Copy link
Contributor

@saghm saghm commented Nov 16, 2018

No description provided.

Copy link
Contributor

@p-mongo p-mongo left a comment

Choose a reason for hiding this comment

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

I would like the error label parsing to also be unit tested (i.e., in addition to other parser unit tests) rather than having to run the transaction spec tests to verify correct parsing.

if err_doc && err_doc['errorLabels']
err_doc['errorLabels'].each do |label|
add_label(label)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a Mongo::Error::Parser which parses all the other fields out of the result, how come this code is added to the exception class and not to the parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I'll change it to do that

{
'errorContains' => e.message,
'errorLabels' => e.instance_variable_get(:@labels) || []
'errorLabels' => e.instance_variable_get(:@labels)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think Mongo::Error should have a labels method added following this part of https://github.com/mongodb/specifications/blob/master/source/transactions/transactions.rst#error-reporting-changes:

Drivers MAY expose the list of all error labels for an exception object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

@saghm
Copy link
Contributor Author

saghm commented Nov 16, 2018

All suggested changes have been made

@saghm
Copy link
Contributor Author

saghm commented Nov 26, 2018

Updated again per offline discussion

Copy link
Contributor

@p-mongo p-mongo left a comment

Choose a reason for hiding this comment

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

Can you please add a test for the error parser parsing labels out of a response? I thought this existed in the previous version of this PR.


def first_document
@first_document ||= reply.documents[0]
@first_document ||= reply && reply.documents[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be now returned to unconditionally reading reply?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@saghm
Copy link
Contributor Author

saghm commented Nov 27, 2018

Sorry, I must have misunderstood how you wanted the tests changed from our offline discussion. I've added the test back and changed it to use Result#raise_operation_failure to ensure the correct code path is covered

@saghm
Copy link
Contributor Author

saghm commented Nov 27, 2018

Added a unit test for the parser

Copy link
Contributor

@p-mongo p-mongo left a comment

Choose a reason for hiding this comment

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

Thanks!

@saghm saghm merged commit 90340ab into mongodb:master Nov 27, 2018
@saghm saghm deleted the RUBY-1587 branch February 26, 2019 20:12
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