CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 1999
    Location
    USA
    Posts
    25

    How can I handle errors that do not throw any Exceptions??



    Can anyone guide me as to how to handle errors that do not throw any exception.

    For example, I frequently get errors from CStringArray.GetAt() function when it goes out of bound. I gave this only for example as they can be hanled by a proper if construct. But still there may be some overlooks. So can anyone guide me as to how to catch such type of errors.


    and also to use set_terminate() function.


    Thanks and Love in advance,

    Samantha Katherine.

  2. #2
    Join Date
    Mar 1999
    Posts
    17

    Re: How can I handle errors that do not throw any Exceptions??



    Let's see if I understand the question: How do you handle error conditions that are

    not detected, is that it?



  3. #3
    Join Date
    Apr 1999
    Posts
    53

    Re: How can I handle errors that do not throw any Exceptions??



    Dear Samantha,


    First, congratulations on even bothering to try and catch the exceptions that ARE thrown! There is an awful lot of production code is out there that doesn't worry about it.


    Unfortunately, if a function does not throw exceptions, it is up to you to trap the condition.


    Now, on IBM-type mainframes, you can have an "ESTAE" exit that the OS jumps into when it hits an abend condition, so at least you can shut down gracefully under all conditions (short of the operator pressing the IPL button). I've never found the equivalent for Windows -- but it may be out there somewhere.


    Also, don't let sarcastic replies get to you. Just ignore them as best you can, and keep using the site.


    Yours,

    Wes Rogers

  4. #4
    Join Date
    Apr 1999
    Posts
    6

    Re: How can I handle errors that do not throw any Exceptions??



    Samantha,

    An innocent reply, as in olden dos times can you safely overload(remembering threading) the interrupts like overflow, divide by zero etc. Try, the processor is the same whether it is dos or windows and it can execute interrupts also, but how don't know. I have seen couple of int 3 in MFC code. If you can you have the solution.

  5. #5
    Join Date
    Jun 1999
    Location
    Indiana, USA
    Posts
    94

    Re: How can I handle errors that do not throw any Exceptions??

    If I have the question correct.... Are these errors supposed to be debugging tools? As in halt the program?

    If I have the question correct, then you are using the code for debuging and program termination.

    Try the Assert function. It even reports the line number of the error!!

    You can look it up in the index, but I think that the library is standard, and that it has the format

    Assert( condition )

    if the condition evaluates to true, the program ends, otherwise it continues normally.
    This is a great debugging and error handling tool! And I commend you on attempting to capture such errors! This is great programming practice!

    you will have to specify the condition, however.

    ///////////////////////////////////////////////////////
    Good things come to those who wait...
    But they come used by the impatient....
    ///////////////////////////////////////////////////////

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured