cartservice: add try catch to GetCartAsync

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-28 21:46:48 -07:00
parent 386f497553
commit f8ddac9c52

View file

@ -81,6 +81,8 @@ namespace cartservice.cartstore
public async Task<Hipstershop.Cart> GetCartAsync(string userId) public async Task<Hipstershop.Cart> GetCartAsync(string userId)
{ {
Console.WriteLine($"GetCartAsync called with userId={userId}"); Console.WriteLine($"GetCartAsync called with userId={userId}");
try
{
var db = redis.GetDatabase(); var db = redis.GetDatabase();
// Access the cart from the cache // Access the cart from the cache
@ -90,6 +92,11 @@ namespace cartservice.cartstore
{ {
return Hipstershop.Cart.Parser.ParseFrom(value); return Hipstershop.Cart.Parser.ParseFrom(value);
} }
}
catch (Exception e)
{
Console.WriteLine(e);
}
// We decided to return empty cart in cases when user wasn't in the cache before // We decided to return empty cart in cases when user wasn't in the cache before
return new Hipstershop.Cart(); return new Hipstershop.Cart();