natverse / neuprintr

R client utilities for interacting with the neuPrint connectome analysis service
http://natverse.org/neuprintr
3 stars 3 forks source link

More informative errors for neuprint_fetch_custom? #38

Closed romainFr closed 4 years ago

romainFr commented 4 years ago

In neuprint explorer, you get error messages that detail why a given query fails. If there's a way to grab those through the API that would be more useful that the HTTP error codes we're now getting.

jefferis commented 4 years ago

@romainFr If you give me a query with error, can show you how to get that.

jefferis commented 4 years ago

@romainFr can you give an example here?

romainFr commented 4 years ago

If I run a large query, in neuprint explorer I'd get a message expliciting that the problem is a time out (this happens with path queries easily):

Error: Post http://neo4j:n304jT35t@neo4j-test.int.janelia.org:7474/db/data/transaction: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

Whereas in neuprintr, we only return Bad Request (HTTP 400). In general anywhere we get a 'Bad Request`, I'm wondering if there's a way to obtain the server error message.

(other example, when querying a shortest path with identical neurons in the input and output side, we get a bad request, whereas neuprint explorer returns:

Error: The shortest path algorithm does not work when the start and end nodes are the same. This can happen if you perform a shortestPath search after a cartesian product that might have the same start and end nodes for some of the rows passed to shortestPath. If you would rather not experience this exception, and can accept the possibility of missing results for those rows, disable this in the Neo4j configuration by setting cypher.forbid_shortestpath_common_nodesto false. If you cannot accept missing results, and really want the shortestPath between two common nodes, then re-write the query using a standard Cypher variable length pattern expression followed by ordering by path length and limiting to one result. )

jefferis commented 4 years ago

Thanks @romainFr. But can you give an actual R snippet that fails?

jefferis commented 4 years ago

I think the issue is that the server returns an error code which triggers an R error before we ever get to inspect the details of the request to extract more information.

https://github.com/natverse/neuprintr/blob/ea20c16da03193d9754af79fd51dabae556b7611/R/fetch.R#L15-L26

Basically if we get a 400 status instead of throwing an error immediately we should extract the error details and then throw the error.

romainFr commented 4 years ago

neuprint_get_paths(c(1128092885,481121605),5813041365,3,weightT=20,all_segments = FALSE) will give the time out for example