Click here to Skip to main content
15,901,001 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to change the attributes of a file? Pin
Abin5-Sep-02 4:53
Abin5-Sep-02 4:53 
AnswerRe: How to change the attributes of a file? Pin
José Luis Sogorb25-Oct-02 2:18
José Luis Sogorb25-Oct-02 2:18 
GeneralFTP transfer using Shell API Pin
Dmitry Ivanov5-Sep-02 4:08
Dmitry Ivanov5-Sep-02 4:08 
QuestionAnyone here know TAPI 2? Pin
twomagiclovers5-Sep-02 3:55
twomagiclovers5-Sep-02 3:55 
AnswerRe: Anyone here know TAPI 2? Pin
Ernest Laurentin5-Sep-02 7:23
Ernest Laurentin5-Sep-02 7:23 
Generalhelp with try catch Pin
ns5-Sep-02 3:32
ns5-Sep-02 3:32 
GeneralRe: help with try catch Pin
Tomasz Sowinski5-Sep-02 3:42
Tomasz Sowinski5-Sep-02 3:42 
GeneralRe: help with try catch Pin
Pavel Klocek5-Sep-02 4:11
Pavel Klocek5-Sep-02 4:11 
Exception handling is intended as it's name says for handling of exceptional/error conditions. Don't use it to control a normal flow of your program - it has it's cost. Throw an exception if an error occured, which you don't want or can't handle in place.

Maybe you're using a class to access registry which generates exceptions. Then you need to use try/catch, see the class doc.

If you are using API functions or a class which doesn't use exceptions, the choise is on you.

The exceptions would be appropriate, if more error conditions can occure in your code with the same handling. State of your data (close or not close) is in your hands. Simple example throwing na int for simplicity:

try
{
    if(!keyOpen(...)) throw 1;
    if(!keyRead(...)) throw 2;
    keyClose(...);
    if(!keyOpen(...)) throw 1;
    if(!keyRead(...)) throw 2;
    keyClose(...);
    ...
}
catch(int i)
{
    if(i>1) keyClose(...);
    MsgBox("err");
    return false;
}


Pavel
Sonork 100.15206
GeneralRe: help with try catch Pin
ns5-Sep-02 8:21
ns5-Sep-02 8:21 
GeneralRe: help with try catch Pin
Alexandru Savescu5-Sep-02 23:23
Alexandru Savescu5-Sep-02 23:23 
QuestionHow can I know which computer access the file of my computer? Pin
Member 18556085-Sep-02 2:53
Member 18556085-Sep-02 2:53 
QuestionHow can I know which computer access the file of my computer? Pin
Anonymous5-Sep-02 2:53
Anonymous5-Sep-02 2:53 
GeneralButton Controls in OnCtlColor() Pin
adamUK5-Sep-02 2:47
adamUK5-Sep-02 2:47 
GeneralRe: Button Controls in OnCtlColor() Pin
Tomasz Sowinski5-Sep-02 2:57
Tomasz Sowinski5-Sep-02 2:57 
GeneralRe: Button Controls in OnCtlColor() Pin
adamUK5-Sep-02 3:13
adamUK5-Sep-02 3:13 
QuestionHow can I know which computer access the file of my computer? Pin
Anonymous5-Sep-02 2:44
Anonymous5-Sep-02 2:44 
GeneralDynamically compiling files into a new EXE Pin
Ambit5-Sep-02 2:26
Ambit5-Sep-02 2:26 
GeneralRe: Dynamically compiling files into a new EXE Pin
Stephane Rodriguez.5-Sep-02 2:40
Stephane Rodriguez.5-Sep-02 2:40 
GeneralRe: Dynamically compiling files into a new EXE Pin
Ambit5-Sep-02 4:24
Ambit5-Sep-02 4:24 
GeneralRe: Dynamically compiling files into a new EXE Pin
Stephane Rodriguez.5-Sep-02 4:43
Stephane Rodriguez.5-Sep-02 4:43 
GeneralA C++ related question Pin
5-Sep-02 1:59
suss5-Sep-02 1:59 
GeneralRe: A C++ related question Pin
Tomasz Sowinski5-Sep-02 2:16
Tomasz Sowinski5-Sep-02 2:16 
GeneralRe: A C++ related question Pin
56789012345-Sep-02 2:17
56789012345-Sep-02 2:17 
GeneralRe: A C++ related question Pin
Gary R. Wheeler5-Sep-02 2:29
Gary R. Wheeler5-Sep-02 2:29 
GeneralSending mail using ShellExecute Pin
Jawache5-Sep-02 1:50
Jawache5-Sep-02 1:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.