Solved

OWL exception handling

Posted on 1997-09-27
3
307 Views
Last Modified: 2013-12-26
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?
0
Comment
Question by:weltech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
LucHoltkamp earned 100 total points
ID: 1299402
Owl's TApplication::Run() has an internal try-catch block. Any exceptions it doesn't recognize from OWL itself are treated as the Unhandled Exception thing you get. The exception you want to catch in OwlMain never gets there. You'll have to catch the exception before Owl does.
.luc.
0
 

Expert Comment

by:rharlicker
ID: 1299403
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.

0
 

Author Comment

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

0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question