Skip to content

Commit

Permalink
Add actual error as the cause
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuvindu committed Jul 16, 2024
1 parent 40c1402 commit 2c85bf9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
12 changes: 6 additions & 6 deletions ballerina/modules/soap11/soap11.bal
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public isolated client class Client {
check response[0].getXml().clone(), false);
}
}
} on fail var e {
return error Error(INVALID_OUTBOUND_SECURITY_ERROR, e.cause());
} on fail error soapError {
return error Error(INVALID_OUTBOUND_SECURITY_ERROR, soapError);
}
return response;
}
} on fail var e {
return error Error(SOAP_ERROR, e.cause());
} on fail error soapError {
return error Error(SOAP_ERROR, soapError);
}
}

Expand All @@ -122,8 +122,8 @@ public isolated client class Client {
securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone(), false);
}
return check soap:sendOnly(securedBody, self.soapClient, action, headers, path, false);
} on fail var e {
return error Error(SOAP_ERROR, e.cause());
} on fail error soapError {
return error Error(SOAP_ERROR, soapError);
}
}
}
12 changes: 6 additions & 6 deletions ballerina/modules/soap12/soap12.bal
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public isolated client class Client {
check response[0].getXml().clone());
}
}
} on fail var e {
return error Error(INVALID_OUTBOUND_SECURITY_ERROR, e.cause());
} on fail error soapError {
return error Error(INVALID_OUTBOUND_SECURITY_ERROR, soapError);
}
return response;
}
} on fail var e {
return error Error(SOAP_ERROR, e.cause());
} on fail error soapError {
return error Error(SOAP_ERROR, soapError);
}
}

Expand All @@ -122,8 +122,8 @@ public isolated client class Client {
securedBody = check soap:applySecurityPolicies(self.inboundSecurity.clone(), envelope.clone());
}
return check soap:sendOnly(securedBody, self.soapClient, action, headers, path);
} on fail var e {
return error Error(SOAP_ERROR, e.cause());
} on fail error soapError {
return error Error(SOAP_ERROR, soapError);
}
}
}
8 changes: 4 additions & 4 deletions ballerina/modules/wssec/signature.bal
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ isolated class Signature {
return check crypto:signRsaSha512(data, privateKey);
}
}
} on fail var e {
return error Error("Error occurred while signing the data", e.cause());
} on fail error signatureError {
return error Error("Error occurred while signing the data", signatureError);
}
}

Expand All @@ -65,8 +65,8 @@ isolated class Signature {
return check crypto:verifyRsaSha512Signature(data, signature, publicKey);
}
}
} on fail var e {
return error Error("Error occurred while verifying the signature", e.cause());
} on fail error signatureError {
return error Error("Error occurred while verifying the signature", signatureError);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ballerina/modules/wssec/ws_security_methods.bal
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ isolated function applyEncryptedKey(string envelopeString, crypto:PrivateKey sym
securedEnvelope = regexp:replace(re `<wsse:SecurityTokenReference .*/>`, securedEnvelope, replace);
}
return securedEnvelope;
} on fail var e {
return error Error("Error occurred while applying the encrypted key to the envelope", e.cause());
} on fail error encryptionError {
return error Error("Error occurred while applying the encrypted key to the envelope", encryptionError);
}
}

Expand Down
8 changes: 4 additions & 4 deletions ballerina/soap_utils.bal
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public isolated function applyOutboundConfig(OutboundSecurityConfig outboundSecu
}
}
return soapEnvelope;
} on fail var e {
return error Error("Outbound security configurations do not match with the SOAP response.", e.cause());
} on fail error soapError {
return error Error("Outbound security configurations do not match with the SOAP response", soapError);
}
}

Expand All @@ -114,8 +114,8 @@ public isolated function sendReceive(xml|mime:Entity[] body, http:Client httpCli
return check createSoapResponse(response);
}
return check createSoapResponse(response);
} on fail var err {
return error Error(SOAP_RESPONSE_ERROR, err);
} on fail var soapError {
return error Error(SOAP_RESPONSE_ERROR, soapError);
}
}

Expand Down

0 comments on commit 2c85bf9

Please sign in to comment.