imranmomin / Hangfire.AzureCosmosDb

Azure Cosmos DB storage provider for Hangfire
https://www.hangfire.io/
MIT License
17 stars 16 forks source link

GetJobData throws an exception when the job doesn't exist #24

Closed bzumhagen closed 3 years ago

bzumhagen commented 3 years ago

https://github.com/imranmomin/Hangfire.AzureCosmosDb/blob/1ed52d4ff05c34ba11654ca20c27786bd2c2ee13/src/CosmosDbConnection.cs#L90

The azure client throws exceptions for 404s, so if the intended behavior is to return null for a non-existent job, this should be caught.

Something like

catch (CosmosException e) when (e.StatusCode == HttpStatusCode.NotFound)
{
    return null
}
imranmomin commented 3 years ago

Yes - it is intended to return. I have added the try-catch to the call. Will soon release the fixes along with others