Skip to content

Commit 46f8de7

Browse files
committed
Improve error messages hub-client
1 parent 9edc72c commit 46f8de7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Diff for: ballerina/hub_client.bal

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ public isolated client class HubClient {
7777
json|xml|byte[] payload = retrieveRequestPayload(contentType, message.content);
7878
request.setPayload(payload);
7979
error? result = request.setContentType(contentType);
80-
if (result is error) {
81-
return error ContentDeliveryError(
82-
"Error occurred while setting content type", result, statusCode = http:STATUS_BAD_REQUEST);
80+
if result is error {
81+
string errorMsg = string `Error occurred while setting content type: ${result.message()}`;
82+
return error ContentDeliveryError(errorMsg, result, statusCode = http:STATUS_BAD_REQUEST);
8383
}
8484
request.setHeader(LINK, self.hubLinks);
8585
string? secret = self.secret;
@@ -88,15 +88,15 @@ public isolated client class HubClient {
8888
if hash is byte[] {
8989
request.setHeader(X_HUB_SIGNATURE, string `${SHA256_HMAC}=${hash.toBase16()}`);
9090
} else {
91-
return error ContentDeliveryError(
92-
"Error retrieving content signature", hash, statusCode = http:STATUS_BAD_REQUEST);
91+
string errorMsg = string `Error retrieving content signature: ${hash.message()}`;
92+
return error ContentDeliveryError(errorMsg, hash, statusCode = http:STATUS_BAD_REQUEST);
9393
}
9494
}
9595
http:Response|error response = self.httpClient->post("", request);
9696
if response is http:Response {
9797
return processSubscriberResponse(response, self.topic);
9898
} else {
99-
string errorMsg = string `Content distribution failed for topic [${self.topic}]`;
99+
string errorMsg = string `Content distribution failed for topic [${self.topic}]: ${response.message()}`;
100100
return error ContentDeliveryError(errorMsg, statusCode = http:STATUS_INTERNAL_SERVER_ERROR);
101101
}
102102
}

0 commit comments

Comments
 (0)