public void Constructor_NullMessage_ShouldSetFixedMessageAndSetResultCode() { var exception = new RfcInvalidParameterException(null); exception.Message.Should().Be("SAP RFC Error: RFC_INVALID_PARAMETER"); exception.ResultCode.Should().Be(RfcResultCodes.RFC_INVALID_PARAMETER); }
public void Constructor_Message_ShouldSetMessageAndSetResultCode() { var exception = new RfcInvalidParameterException("Test message"); exception.Message.Should().Be("SAP RFC Error: RFC_INVALID_PARAMETER with message: Test message"); exception.ResultCode.Should().Be(RfcResultCodes.RFC_INVALID_PARAMETER); }
public static void handleException(Exception e, bool isInputParam, String currentParamName, String actionName, bool manualContext, RfcDestination destination, String functionOriginalName) { if (e is RfcInvalidParameterException) { RfcInvalidParameterException ipex = (RfcInvalidParameterException)e; if (!manualContext) { IRfcFunction rollbackFunc = destination.Repository.CreateFunction("BAPI_TRANSACTION_ROLLBACK"); rollbackFunc.Invoke(destination); } throw new SapException("Failed to call the '" + actionName + "' SAP remote function, as its parameters don't match those on the SAP server. Check the remote function signature on the SAP server and in your module. SAP exception: " + ipex.Message, e); } if (e is RfcTypeConversionException) { RfcTypeConversionException tcex = (RfcTypeConversionException)e; if (!manualContext) { IRfcFunction rollbackFunc = destination.Repository.CreateFunction("BAPI_TRANSACTION_ROLLBACK"); rollbackFunc.Invoke(destination); } throw new SapException("Invalid value " + (isInputParam ? "received" : "sent") + " in the '" + currentParamName + "' parameter on the '" + actionName + "' SAP remote function. Review the parameter's data type. SAP exception: " + tcex.Message, e); } if (e is RfcLogonException) { RfcLogonException lex = (RfcLogonException)e; throw new SapException("SAP authentication failed. Check if your SAP user credentials are valid. SAP exception: " + lex.Message, e); } if (e is RfcCommunicationException) { RfcCommunicationException cex = (RfcCommunicationException)e; throw new SapException("Communication with SAP failed. SAP exception: " + cex.Message, e); } if (e is RfcInvalidStateException) { RfcInvalidStateException isex = (RfcInvalidStateException)e; if (isex.Message.Contains("FU_NOT_FOUND")) { throw new SapException("SAP remote function '" + functionOriginalName + "' was not found.", e); } throw new SapException("Invalid value " + (isInputParam ? "received" : "sent") + " in the '" + currentParamName + "' parameter on the '" + actionName + "' SAP remote function. Review the parameter's data type. SAP exception: " + isex.Message, e); } if (e is RfcAbapException) { RfcAbapException aex = (RfcAbapException)e; if (!manualContext) { IRfcFunction rollbackFunc = destination.Repository.CreateFunction("BAPI_TRANSACTION_ROLLBACK"); rollbackFunc.Invoke(destination); } throw new SapException("Failed to execute the '" + actionName + "' SAP remote function. SAP exception: " + aex.Message, e); } throw e; }