Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Catching Exception under CLANG and TIdTCPClient


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 4 - Last Post: Dec 28, 2016 2:30 PM Last Post By: Petr Vykouk
Petr Vykouk

Posts: 42
Registered: 6/4/00
Catching Exception under CLANG and TIdTCPClient  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2016 8:18 AM
It is possible (and if is, how ?) catch exception TIdTCPClientCustom::Connect() method under CLANG compiler? Berlin 10.1 Upd2

bool error;

try
{
IdTCPClient->Connect();
error = false;
}
catch (...)
{
error = true; // <--- never reach this line
}

Any suggestion how to detect unsuccessful connect() ?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Catching Exception under CLANG and TIdTCPClient  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2016 9:43 AM   in response to: Petr Vykouk in response to: Petr Vykouk
Petr wrote:

It is possible (and if is, how ?) catch exception
TIdTCPClientCustom::Connect() method under
CLANG compiler?

Have you tried catching an actual class type instead of using '...'?

bool error;
 
try
{
    IdTCPClient->Connect();
    error = false;
}
catch (const Exception &)
{
    error = true;
}


Also, please read Embarcadero's documentation about exception handling in
the clang compilers:

Differences Between Clang-enhanced C++ Compilers and Previous-Generation
C++ Compilers
Try Blocks Cannot Handle Some Exceptions

http://docwiki.embarcadero.com/RADStudio/en/Differences_Between_Clang-enhanced_C%2B%2B_Compilers_and_Previous-Generation_C%2B%2B_Compilers#Try_Blocks_Cannot_Handle_Some_Exceptions

--
Remy Lebeau (TeamB)
Petr Vykouk

Posts: 42
Registered: 6/4/00
Re: Catching Exception under CLANG and TIdTCPClient  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2016 11:07 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Petr wrote:

It is possible (and if is, how ?) catch exception
TIdTCPClientCustom::Connect() method under
CLANG compiler?

Have you tried catching an actual class type instead of using '...'?

bool error;
 
try
{
    IdTCPClient->Connect();
    error = false;
}
catch (const Exception &)
{
    error = true;
}


Also, please read Embarcadero's documentation about exception handling in
the clang compilers:

Differences Between Clang-enhanced C++ Compilers and Previous-Generation
C++ Compilers
Try Blocks Cannot Handle Some Exceptions

http://docwiki.embarcadero.com/RADStudio/en/Differences_Between_Clang-enhanced_C%2B%2B_Compilers_and_Previous-Generation_C%2B%2B_Compilers#Try_Blocks_Cannot_Handle_Some_Exceptions

--
Remy Lebeau (TeamB)

Remy,

exe compiled in debug mode works without IDE ok, but release exe never reach the catch (const Exception &ex) block.
With 'classic' compiler run fine.
Suggestion from documentation:"Move the code that may raise an asynchronous exception to its own function and call that function from your try block" is not helping.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Catching Exception under CLANG and TIdTCPClient  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2016 11:22 AM   in response to: Petr Vykouk in response to: Petr Vykouk
Petr wrote:

exe compiled in debug mode works without IDE ok, but release exe
never reach the catch (const Exception &ex) block.

With 'classic' compiler run fine.

Then you should file a bug report with Embarcadero.

Suggestion from documentation:"Move the code that may raise an
asynchronous exception to its own function and call that function
from your try block" is not helping.

Because an asynchronous exception is not involved in this situation.

--
Remy Lebeau (TeamB)
Petr Vykouk

Posts: 42
Registered: 6/4/00
Re: Catching Exception under CLANG and TIdTCPClient  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 28, 2016 12:28 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Petr wrote:

exe compiled in debug mode works without IDE ok, but release exe
never reach the catch (const Exception &ex) block.

With 'classic' compiler run fine.

Then you should file a bug report with Embarcadero.

Suggestion from documentation:"Move the code that may raise an
asynchronous exception to its own function and call that function
from your try block" is not helping.

Because an asynchronous exception is not involved in this situation.

--
Remy Lebeau (TeamB)

Under Win64 Target Platform works all as expected.

see: https://quality.embarcadero.com/browse/RSP-16627

Edited by: Petr Vykouk on Dec 28, 2016 2:30 PM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02