Add error logging
This commit is contained in:
parent
7e0752956b
commit
11d792f220
1 changed files with 15 additions and 10 deletions
|
@ -16,20 +16,22 @@ service RecommendationService on new grpc:Listener(8080) {
|
|||
// Fetch list of products from product catalog stub
|
||||
var products = catalogClient->ListProducts(req);
|
||||
if (products is grpc:Error) {
|
||||
log:printError("Error when retrieving products: " + products.reason() + " - "
|
||||
+ <string>products.detail()["message"]);
|
||||
log:printError("Error when retrieving products", products);
|
||||
|
||||
// Return a fixed set of recommendations on error.
|
||||
ListRecommendationsRequest response = {
|
||||
user_id: value.user_id,
|
||||
product_ids: ["9SIQT8TOJO", "6E92ZMYYFZ", "LS4PSXUNUM"]
|
||||
};
|
||||
|
||||
var e = caller->send(response);
|
||||
e = caller->complete();
|
||||
|
||||
if (e is error) {
|
||||
log:printError("Error when sending recommendations: " + e.reason() + " - "
|
||||
+ <string>e.detail()["message"]);
|
||||
log:printError("Error when sending recommendations", e);
|
||||
}
|
||||
|
||||
e = caller->complete();
|
||||
if (e is error) {
|
||||
log:printError("Error when sending recommendations", e);
|
||||
}
|
||||
} else {
|
||||
// Get the ListProductResponse from the union typed value.
|
||||
|
@ -61,12 +63,15 @@ service RecommendationService on new grpc:Listener(8080) {
|
|||
user_id: value.user_id,
|
||||
product_ids: filteredProducts.reverse()
|
||||
};
|
||||
var e = caller->send(response);
|
||||
e = caller->complete();
|
||||
|
||||
var e = caller->send(response);
|
||||
if (e is error) {
|
||||
log:printError("Error when sending recommendations: " + e.reason() + " - "
|
||||
+ <string>e.detail()["message"]);
|
||||
log:printError("Error when sending recommendations", e);
|
||||
}
|
||||
|
||||
e = caller->complete();
|
||||
if (e is error) {
|
||||
log:printError("Error when sending recommendations", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue