Elfocrash / Cosmonaut

🌐 A supercharged Azure CosmosDB .NET SDK with ORM support
https://cosmonaut.readthedocs.io
MIT License
342 stars 44 forks source link

DocumentClientException Success instead of NotFound #46

Closed fileman closed 5 years ago

fileman commented 5 years ago

Hi, I've a test for NotFound resource by using wrong id. DocumentClient throw this exception "Microsoft.Azure.Documents.DocumentClientException: Message: {"Errors":["Resource Not Found"]}" in Visual Studio Locals tab $exception variable, but CosmonautClient return Success and no exception catched.

try
{
       result = await cosmosService.EntityStore.UpdateAsync(Entity.Value);
}
catch (DocumentClientException ex)
{
       var error = ex; //Breakpoint here ignored
       throw;
}

return result.Exception is null ? // this is null
     (ActionResult)new OkObjectResult($"Success") : 
     new BadRequestObjectResult($"Error");
Elfocrash commented 5 years ago

Cosmonaut does not throw for any document related exception and it does not return them either.

In the case of not found it should set the operation status to NotFound.

This is described in the readme and the docs: https://cosmonaut.readthedocs.io/en/latest/The-CosmosStore.html#cosmosresponse-and-response-handling

fileman commented 5 years ago

yes, I've readed it, but with wrong id in the UpdateAsync returned value CosmosOperationStatus is set to Success image I can't find why not found resource return success, something to check?

Elfocrash commented 5 years ago

Oh ok I see. I will try to reproduce and get back to you. It should be a failure but not throw.

Elfocrash commented 5 years ago

Issue fixed. Will be part of the new 2.8.0 release.