-
Notifications
You must be signed in to change notification settings - Fork 27
Clarify error statuses returned by native drivers #257
Comments
It's documented that the user should check the status code in the Reading and Interpreting the Response section. |
This is what is written in docs. I think this means that clients should raise an error/exception for all statuses other than |
The full quote, emphasis mine:
I think it's clear in saying that the status should be checked. It doesn't say that the clients should raise an exception. Once that's said, we can talk about if we want the clients to raise an exception for the |
Sure, it's written clearly, but bblfsh/java-driver#77 shows that no one reads it ;) So I think it might make sense to raise an error for these cases. The point about performance penalty is significant enough. Will think about it a bit more. |
Could be an Optional in Scala which AFAIK doesn't have the performance penalty of exceptions and force the user to check them before usage. |
Scala's You have other options to avoid exceptions: Define a
Semantics of |
I read the docs that you mentioned guys, and I personally think that we just should add something more to it. Because in case of not I found another piece of documentation here: https://doc.bblf.sh/driver/internal-protocol.html
and maybe we should just add this clarification to the part @juanjux mentioned: https://doc.bblf.sh/user/server-grpc-example.html#reading-and-interpreting-the-response I do not think this it is worth errors to throw an exception. |
@smola but this would require throwing an exception internally anyway, doesn't it? My concern is that Exceptions have an effect in performance in C++ and Java and by extension I guess in Scala (not much in Python unless things have changed since I tested it). Maybe we could write something similar to Option that returns the error and the partial UAST if the driver provides it instead of None. |
@juanjux |
Or maybe we should just stress this in our docs. It doesn't help if our own official examples do not check status ;) And there could be further reminders here: And expand the description about how to use Maybe in some other places too. |
That example on the language clients page is pretty weak. Not only it doesn't check the |
@smola PTAL bblfsh/documentation/pull/160 Personally, I preferred the previous version in Python before it was nuked by the previous lead since: 1) It's still a lot more used than Go and thus more readers would be able to get it and 2) Shows that bblfsh is not a "go-only" project for users. What do you think? |
@juanjux Examples in multiple languages would be nice in the docs. Go, Python and Scala, ideally. |
I agree, I'll do it. |
Since the v2 protocol is going live, it's the right time to revisit this for client libraries. |
Done, see #321 |
Babelfish drivers may return 3 main statuses:
OK
,Error
,Fatal
.Currently, there is no guarantee that
Error
responses will have a partial AST, since it's not tested in any of the drivers.At the same time,
Error
status is not considered an error/exception in clients as reported in bblfsh/java-driver#77, thus clients might not be aware that they receive a partial AST.We should either:
a) Make a special type of error/exception that user code should assert to accept a partial AST. In this case clients will receive an error in case of any syntax erros, which might be a desired behavior.
b) Mention current behavior in Babelfish docs, clarify that user should check the status.
Personally, I would prefer the first option.
The text was updated successfully, but these errors were encountered: