04-29-2016 08:57 AM
Does a documented list exist of error codes and messages which can occur when using the REST API ? For instance "file not found" is a message, but I could not find an associated errorcode. Is there a recommended way on handling these errors (in PHP)?
05-12-2016 11:51 AM
I will try to semi answer myself. Semi as in: it is probably not a full answer, but provides some insights which might be helpful for others. When calling the following code with a query which results in an empty resultset, because for instance the workspace is empty a general(!) exception is being raised/thrown, so error 0 = File Not Found. But this makes you wonder: why not a Nuxeo exception? Is an empty resultset a problem by default? Is the resultset empty because the query failed (unknown workspace for instance) or just because the workspace does not contain files?
I would love to see some documentation on this subject. Originally I made my question general as similar issues might exist for other languages/clients as well. Now I am pinpointing this to the PHP client lib as that is the one I am using. It could also be that the effects are not there by design and this should be filed as a bug, but as I have not found specs/docs as mentioned before I am not sure.
PHP Code:
try {
$nuxeo->documentQuery($query);
}
catch (NuxeoClientException $ex) {
//$previous = $ex->getPrevious();
$statuscode = $ex->getCode(); // $previous->getResponse()->getStatusCode() ;
$errormessage = $ex->GetMessage(); //$previous->getResponse()->getMessage() ;
echo ("NE Query '".$query."' resulted in error ".$statuscode." : ".$errormessage."\n");
}
catch (Exception $e) {
$statuscode = $e->getCode();
$errormessage = $e->GetMessage();
echo ("GE Query '".$query."' resulted in error ".$statuscode." : ".$errormessage."\n");
}
05-18-2016 08:43 AM
Hi Olaf,
Using your code (only by adjusting the try body part), the client correctly throw a NuxeoClientException :
$query = "SELECT * FROM Document WHERE ecm:primaryType = 'Note'";
try {
$session = $client->getSession($nuxusr, $nuxusr);
$answer = $session->newRequest("Document.Query")
->set('params', 'query', $query)
->setSchema("*")
->sendRequest();
$documentsArray = $answer->getDocumentList();
echo count($documentsArray);
}catch (NuxeoClientException $ex) {
$statuscode = $ex->getCode(); // $previous->getResponse()->getStatusCode() ;
$errormessage = $ex->GetMessage(); //$previous->getResponse()->getMessage() ;
echo ("NE Query '".$query."' resulted in error ".$statuscode." : ".$errormessage."\n");
}catch (Exception $e) {
$statuscode = $e->getCode();
$errormessage = $e->GetMessage();
echo ("GE Query '".$query."' resulted in error ".$statuscode." : ".$errormessage."\n");}
NE Query 'SELECT * FROM Document WHERE ecm:primaryType = 'Note'' resulted in error 0 : file not found
Maybe there's something in the class of your $nuxeo object causing that exception to be raised as a something else than a NCE.
The behaviour comes from the NuxeoDocuments class in the PHP client. If you have a look at the code, you will notice that once the response has been parsed from JSON, if the entries node is empty and there's no uid node (which means the response is neither a collection of documents nor a single document), a NuxeoClientException is raised with the single message "file not found". That shall be improved in a future release.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.