Link to home
Start Free TrialLog in
Avatar of weltech
weltech

asked on

OWL exception handling

I am writing for 16-bit Windows using ObjectWindows from Borland C++ 4.52.
By following the examples I can generate & trap specific exceptions.
My problem is to trap exceptions generated by the following fragment:

   char str [100], *sptr = 0;
   strcpy (str, sptr);

Which makes strcpy() take a NULL pointer and generate an Unhandled Exception.

int OwlMain(int /*argc*/, char* /*argv*/ [])
{
   try
      {
      return TDrawApp().Run();
      }
   catch (xmsg& x)
      {
      ::MessageBox(0, x.why().c_str(), "Exception", MB_OK);
      return -1;
      }
   catch (...)
      {
      ::MessageBox(0, "Error Trap", "Exception", MB_OK);
      }
   return -1;
}


I cannot catch the error. Why?
ASKER CERTIFIED SOLUTION
Avatar of LucHoltkamp
LucHoltkamp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rharlicker
rharlicker

Note: This is for 16bit apps only.

Search the internet for the file fault.zip . It includes documentation and sources that show how to trap GPF's by hooking
into the InterruptRegister routine.

Avatar of weltech

ASKER

Thank you rharlicker
This form doesn't appear to give me a Reward option.
Please take 50 points.