I have a application to connect SAP with an RFC call and I need to show a notification to the user when connection failed while try to establish the RFC call with SAP. And I'm getting the following exception.
{
SAP.Middleware.Connector.RfcCommunicationException:
LOCATION CPIC (TCP/IP) on local host with Unicode
ERROR partner '151.9.39.8:8010' not reached
TIME Wed Jul 16 10:32:05 2014
RELEASE 720
COMPONENT NI (network interface)
VERSION 40
RC -10
MODULE nixxi.cpp
LINE 3286
DETAIL NiPConnect2: 151.9.39.8:8010
SYSTEM CALL connect
ERRNO 10060
ERRNO TEXT WSAETIMEDOUT: Connection timed out
COUNTER 2
}
And by using this exception I need to notify the user. But how can I identify whether it is a SAP.Middleware.Connector.RfcCommunicationException or not because I'm handling other exceptions too. Is there any way to get the type of the exception without concatenating the above exception string.
In my try catch block I'm currently doing this but it is not working.
catch (Exception ex)
{
if (ex.ToString().ToLower() == "rfccommunicationexception")
{
MessageError = "RFC error";
}
}
Catch the exception explicitly:
catch(SAP.Middleware.Connector.RfcCommunicationException)
{
// RFC exception
}
catch(Exception e)
{
// All other exceptions
}
The best approach to this is to have multiple catch blocks:
try
{
// your code
}
catch(RfcCommunicationException rfcEx)
{
// handle rfc communication exception
}
cathc(Exception ex)
{
// handle other exception
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With