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
|
// Fetch list of products from product catalog stub
|
||||||
var products = catalogClient->ListProducts(req);
|
var products = catalogClient->ListProducts(req);
|
||||||
if (products is grpc:Error) {
|
if (products is grpc:Error) {
|
||||||
log:printError("Error when retrieving products: " + products.reason() + " - "
|
log:printError("Error when retrieving products", products);
|
||||||
+ <string>products.detail()["message"]);
|
|
||||||
|
|
||||||
// Return a fixed set of recommendations on error.
|
// Return a fixed set of recommendations on error.
|
||||||
ListRecommendationsRequest response = {
|
ListRecommendationsRequest response = {
|
||||||
user_id: value.user_id,
|
user_id: value.user_id,
|
||||||
product_ids: ["9SIQT8TOJO", "6E92ZMYYFZ", "LS4PSXUNUM"]
|
product_ids: ["9SIQT8TOJO", "6E92ZMYYFZ", "LS4PSXUNUM"]
|
||||||
};
|
};
|
||||||
|
|
||||||
var e = caller->send(response);
|
var e = caller->send(response);
|
||||||
e = caller->complete();
|
|
||||||
|
|
||||||
if (e is error) {
|
if (e is error) {
|
||||||
log:printError("Error when sending recommendations: " + e.reason() + " - "
|
log:printError("Error when sending recommendations", e);
|
||||||
+ <string>e.detail()["message"]);
|
}
|
||||||
|
|
||||||
|
e = caller->complete();
|
||||||
|
if (e is error) {
|
||||||
|
log:printError("Error when sending recommendations", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get the ListProductResponse from the union typed value.
|
// Get the ListProductResponse from the union typed value.
|
||||||
|
@ -61,12 +63,15 @@ service RecommendationService on new grpc:Listener(8080) {
|
||||||
user_id: value.user_id,
|
user_id: value.user_id,
|
||||||
product_ids: filteredProducts.reverse()
|
product_ids: filteredProducts.reverse()
|
||||||
};
|
};
|
||||||
var e = caller->send(response);
|
|
||||||
e = caller->complete();
|
|
||||||
|
|
||||||
|
var e = caller->send(response);
|
||||||
if (e is error) {
|
if (e is error) {
|
||||||
log:printError("Error when sending recommendations: " + e.reason() + " - "
|
log:printError("Error when sending recommendations", e);
|
||||||
+ <string>e.detail()["message"]);
|
}
|
||||||
|
|
||||||
|
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