Throwing an Exception

Hi,

I have a little piece of code that I do not know why the "an unhandled
exception has occured" msg box pops up.

//....within an initialization function

try {
  device->Write("IFC\n");
} catch (char *str) {

  //....write the type of error in the status bar

  return;
}

The Write function will throw an exception when the GPIB device
responded with an error msg or timed out.

void GPIBDevice::Write(char* command) throw(...)
{

//.......stuff....

  if (ibsta & ERR) {
    printf ("iberr = %d", iberr);
    throw getErrorMsg();
  } //if
} //Write

Everytime when there's an error, my catch statement doesn't activate.
Instead, that "unhandled exception" dialog pops up! how do I make sure
that my catch block gets the exception not the windows JIT debugger?

0
jacksun007 (12)
2/13/2006 7:43:33 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
537 Views

Similar Articles

[PageSpeed] 4

It could be that another kind of exception is being thrown.  You can add 
another block:

catch (...) {
}

to catch "all other" exceptions.  If you put some code in there you can 
follow the stack back to see where it was called from.

Tom

"FefeOxy" <jacksun007@gmail.com> wrote in message 
news:1139859813.114957.119780@o13g2000cwo.googlegroups.com...
> Hi,
>
> I have a little piece of code that I do not know why the "an unhandled
> exception has occured" msg box pops up.
>
> //....within an initialization function
>
> try {
>  device->Write("IFC\n");
> } catch (char *str) {
>
>  //....write the type of error in the status bar
>
>  return;
> }
>
> The Write function will throw an exception when the GPIB device
> responded with an error msg or timed out.
>
> void GPIBDevice::Write(char* command) throw(...)
> {
>
> //.......stuff....
>
>  if (ibsta & ERR) {
>    printf ("iberr = %d", iberr);
>    throw getErrorMsg();
>  } //if
> } //Write
>
> Everytime when there's an error, my catch statement doesn't activate.
> Instead, that "unhandled exception" dialog pops up! how do I make sure
> that my catch block gets the exception not the windows JIT debugger?
> 


0
tserface (3860)
2/13/2006 8:11:56 PM
FefeOxy wrote:

> Hi,
> 
> I have a little piece of code that I do not know why the "an unhandled
> exception has occured" msg box pops up.
> 
> //....within an initialization function
> 
> try {
>   device->Write("IFC\n");
> } catch (char *str) {
> 
>   //....write the type of error in the status bar
> 
>   return;
> }
> 
> The Write function will throw an exception when the GPIB device
> responded with an error msg or timed out.
> 
> void GPIBDevice::Write(char* command) throw(...)
> {
> 
> //.......stuff....
> 
>   if (ibsta & ERR) {
>     printf ("iberr = %d", iberr);
>     throw getErrorMsg();
>   } //if
> } //Write
> 
> Everytime when there's an error, my catch statement doesn't activate.
> Instead, that "unhandled exception" dialog pops up! how do I make sure
> that my catch block gets the exception not the windows JIT debugger?
> 

FefeOxy:

What is the return type of getErrorMsg()? Maybe you need

catch(const char* str)
{

}

David Wilkinson
0
no-reply8010 (1791)
2/13/2006 9:03:33 PM
"FefeOxy" <jacksun007@gmail.com> wrote in message 
news:1139859813.114957.119780@o13g2000cwo.googlegroups.com...
| Hi,
|
| I have a little piece of code that I do not know why the "an unhandled
| exception has occured" msg box pops up.
|
| //....within an initialization function
|
| try {
|  device->Write("IFC\n");
| } catch (char *str) {
|
|  //....write the type of error in the status bar
|
|  return;
| }
|
| The Write function will throw an exception when the GPIB device
| responded with an error msg or timed out.
|
| void GPIBDevice::Write(char* command) throw(...)
| {
|
| //.......stuff....
|
|  if (ibsta & ERR) {
|    printf ("iberr = %d", iberr);
|    throw getErrorMsg();
|  } //if
| } //Write
|
| Everytime when there's an error, my catch statement doesn't activate.
| Instead, that "unhandled exception" dialog pops up! how do I make sure
| that my catch block gets the exception not the windows JIT debugger?
|
OK, what EXACTLY are you throwing?  That's EXACTLY what you need to catch.
Otherwise, you can use ellipses (...) to catch everything, but then you 
won't have access to what was actually thrown.  In this case you need to 
catch whatever is returned by getErrorMsg().
Cheers,
- Ed. 

0
Anon3258 (180)
2/13/2006 10:06:10 PM
Reply:

Similar Artilces:

Update on client side throws exception
Hi all, I'm updating a SQL Server 2008 database table using SqlDataAdapter/DataSets and Visual Studio C# on the client side. TARGET TABLE TO UPDATE: T_Order FIELDS: TAXOR [nvarchar] (255) NULL, TAXPARTSIZE [nvarchar] (255) NULL TAXSBO [nvarchar] (255) NULL TAXGRP [nvarchar] (255) NULL TAXSBGRP [nvarchar] (255) NULL SOURCE TABLE: ConusSolLyr FIELDS: TAXOR [nvarchar] (255) NULL, TAXPARTSIZE [nvarchar] (255) NULL TAXSBO [nvarchar] (255) NULL TAXGRP [nvarchar] (255)...

Join to get "exception" records
I have two queries Q1 and Q2 which have a common ID field. I want to get the records of Q1 except those where the ID exists in Q2. Is there a way to do this? TIA The Query wizard includes an "unmatched query" that will do what you are asking for. -- Hope that helps! RBear3 .. <john@john.com> wrote in message news:46310F54.2030007@john.com... >I have two queries Q1 and Q2 which have a common ID field. > I want to get the records of Q1 except those where the ID > exists in Q2. > > Is there a way to do this? > > TIA Cool! Thank you! RBear3 wrote:...

DispatchMessageW Exception
Our application is built by VS2005 in Visual Basic and run under dotnet framework 2.0. In the past few months, the application will abort randemly with the exception caught before and message "Faulting application hxmain.exe, version 2.0.3707.19991, stamp 4b849822, faulting module msvcr80.dll, version 8.0.50727.1433, stamp 471eb5ae, debug? 0, fault address 0x0001500a." reported in eventlog. The stack trace can't tell us where the application abort Exception Source: System.Windows.Forms Exception Type: System.AccessViolationException Exception Message:...

cannot save word file except tmp
I opened a word file I already worked before and updated and saved it - it is normal so far. After keeping working for a while, when I tried to save it, I got a message saying I cannot save it. The existing file name, while it is still open and i am working now, is suddenly changed to "xxxx.tmp". I had to save as with other name. I used MS Word 2007 Enterprise and worked under 2007 Office Groove. Any comments are welcome. Thanks, ...

ValidationEventArgs.Exception.SourceSchemaObject always null!
Here's my problem: I'm validating a XML file that I generate vs a static schema file, and am trying to get all the validation errors into a format that can be understood by a non-technical user. So I'm registering a ValidationEventHandler with the XmlValidatingReader's delegate, and can get the ValidationEventArgs just fine. Great. Problem is that I need to get the specific element out of the ValidationEventArgs.Exception object so that I can translate what the problem is into plain english for my non-technical users. But the ValidationEventArgs.Exception.SourceSchemaOb...

CString.ReverseFind() and throw
in the help of CString.ReverseFind(), it says int ReverseFind( XCHAR ch ) const throw(); what is this throw? if it is throwing an exception, how to catch it? thanks. WJ On Mon, 9 Jul 2007 14:48:02 -0700, WJ <WJ@discussions.microsoft.com> wrote: >in the help of CString.ReverseFind(), it says > >int ReverseFind( > XCHAR ch >) const throw(); > >what is this throw? if it is throwing an exception, how to catch it? thanks. > >WJ See: Exception Specifications http://msdn2.microsoft.com/en-us/library/wfa0edys(VS.80).aspx -- Doug Harrison Visual C++ MVP...

Should unimplmented pure function throw a compile error?
It's been a while since I have written anything with abstract classes. If I derive a class from my abstract class and do not implement a pure virtual function of the base class in the derived class, shouldn't the compiler throw an error? -- Bruce E. Stemplewski GarXface OCX and C++ Class Library for the Garmin GPS www.stempsoft.com yes, if you try to instantiate the class in your code it should. "Bruce E. Stemplewski " <BruceStemplewski@hotmail.com> wrote in message news:uaGJZhYCFHA.3732@TK2MSFTNGP14.phx.gbl... > It's been a while since I have written anyt...

LINQ Except function
In the following function, when the two xml strings passed in are identical, I get all of the "File" nodes from docRight. I was expecting zero file nodes. I must be using Except() wrong -- can anyone see what I'm doing wrong? public static string FindUniqueOnRight(string xmlLeft, string xmlRight) { XDocument docLeft = XDocument.Parse(xmlLeft); XDocument docRight = XDocument.Parse(xmlRight); var docAddFromRight = from r in docRight.Descendants ("File").Except( from l in docLeft.Descen...

Formula throwing up an error
Can anyone tell me why I should be getting an error. Range("L10:L7800").FormulaArray = "=IF(SUM(--('A Use'!A$1:A$10000&'A Use'!C$1:C$10000=B10&"G house")),"G house","")" B10 by the way is a relative reference. Thank you for your time. Look at where your double quotes are located; each set surrounds something that Excel will treat as a single string. Also, you will need a "&" between each string or variable. "=IF(SUM(--('A Use'!A$1:A$10000&'A Use'!C$1:C$10000=B1...

Rules exception
Here's a strange one: I have a client who is part of a larger organzation. They're constantly getting e-mails from "HQDA Exchange Administrator" that the larger organization is sending around to everyone. My users want to simply ignore these e-mails as they rarely have anything to do with us. I wrote up instructions for using the Rules Wizard to automatically delete the e-mails if "Exchange Administrator" is found in the senders from address. But, for some reason, the rule simply will not delete the e-mails. It will work with any other user name but seems to r...

MFG unhandled script exception error
When I was doing a Reverse Issue on the Manufacturing Component Transaction Entry window I received the following error when I posted: "Unhandled Script Exception: illegal address for field 'End Item Number' in script 'MOP_Reconcile'. Script Terminated". The transaction posted successfully, but I am wondering what caused the error. Does anyone know what this error means? Thanks for your help, Jocelyn ...

AfxOleInit throws an exception
Hi, I am doing a project for Unicode complaiance. The project setting are changed to _UNICODE. The application works fine in Debug mode. But when the configuration is changed to Release 'AfxOleInit' throws an exception. Any idea why this could happen ? Regards, ND Catch the exception and see what it says. try { AfxOleInit(); } catch (CException *pExp) { char Buffer[255]; pExp->GetErrorMessage(Buffer,255,NULL); MessageBox(Buffer); } AliR. "ND" <ND@discussions.microsoft.com> wrote in message news:615E05E3-CC6F-4A40-B18B-0D4233AC32CC@microsoft....

Throwing two dice and print out the total of each throw
in the days of line numbers i build a short programme to simulate the throwing of two dice with a screen print out the number of times, a particular number randomly came up . My question is can this run using Access VB ? Any constructive advise would be most welcome . The old code is as follows: REM THROWING 2 DICE CLS INPUT "How many Throws", N Dim A(12) FOR M = 1 TO 12 A(M) = 0 Next M FOR T = 1 TO N X = int(6 * rnd (1)) + 1 Y = int(6 * rnd (1)) + 1 Z = X + Y A (Z) = A(Z)+1 NEXT T CLS PRINT TAB(5); "Total" ; TAB(25); " Frequency" PRINT...

Addnew throwing error 3027
In one sub I am trying to add a record to to "Abstracts" table. Records in the abstracts table are related to the States and counties tables. So I open a recordset with joins. I have tried several times after checking everything out and cannot find any reason why the recordset should be read only. I have also checked for a lock file (as suggested in another post). The code: Private Sub cmdSave_Click() Dim strSQL As String Dim rs As DAO.Recordset Dim db As DAO.Database If blnCheckFields Then 'save new abstract Set db = CurrentDb() ...

Sum (throw out highest and lowest)
I am working on a contest scoring sheet for the California State Old Time fiddlers Association and it is contest policy to throw out the highest score and the lowest score and add the remaining middle (3) judges scores. (There are generally 5 judges - don't think there would ever be more than that.) The total of the middle three is used for future ranking points added to future scores, so "average" won't work in this application. Right now we are working this out manually - sure woudl be sweet to be able to have a formula that works it out for us. Thanks for any help. ...

XML Serialization of the Exception Class
I am attempting the following: XmlSerializer ser = new XmlSerializer(typeof(Exception)); I receive the following error: Message: There was an error reflecting type 'System.Exception'. Message: The property 'TargetSite' on type 'System.Exception' cannot be serialized because it is decorated with declarative security permission attributes. Consider using imperative asserts or demands in the property accessors. If I had ANY IDEA in the WORLD what this message is trying to tell me I would try to do something about this. Can anyone help me? Thanks In Advance d...

If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The specified network name is no longer available." again. how to clean this up? after this the stream writer is stuck connected until i restart my process. ...

throwing CException
I have extended CException into CMyException. I'm throwing it like this: if (error) throw new CMyException("Message", TRUE); How should I catch it? Is this OK: try { callSomeFunc(); } catch (CException &e) { char msg[999]; e.GetErrorMessage(msg, sizeof(msg)); AfxMessageBox(msg); return; } or I _have_ to use "CException *e"? Also, do I have to call e->Delete() and when? Is this OK: > try { > callSomeFunc(); > } catch (CException &e) { > char msg[999]; > e.GetErrorMessage(msg, sizeof(msg)); > AfxMessageBox(msg); > ...

CFile::GetStatus throws an exception when run from CD
I have a small app that is checking to see if the file dotnetfx.exe is present in the same directory as my executable. I am running VS.NET 2003 and using unmanaged C++. Everything works great, as long as my executable is not on a CD. When burned to CD, the call to GetStatus will throw "the parameter is incorrect". The strings are correct (and obviously it runs fine when not burnt to CD). CString strHelpFilePath = AfxGetApp()->m_pszHelpFilePath; int iFileLoc = strHelpFilePath.ReverseFind(_T('\\')); CString strFxLoc = strHelpFilePath.Left(iFileLoc + 1) + ...

this web site throwing blank pages
anyone else noting that this web site is throwing alot of unreachable web pages suddenly? Right now all my received email notifications of a reply ...the link on that email does not work to the reply.... Also alot of times during the sign-in it goes to nowhere.... -- NTC Yes, the sign-in always breaks/fails half way in and you need to reload to complete the process if using the Web interface. -- Daniel Pineault "NetworkTrade" wrote: > anyone else noting that this web site is throwing alot of unreachable web > pages suddenly? > > Right now all my receive...

CDO throwing Access Denied error in Outlook 2003
Hi, Whenever i access the Messages property of the Contact MAPI Folder, i am getting the following error Collaboration Data Objects Message : [Collaboration Data Objects - [E_ACCESSDENIED(80070005)]] What could be the prob? Thanks Bala I'm not sure what the problem is, your code works fine here but it does throw up the address book access security prompt before access to the contacts folder is allowed. Are you using the Beta 2 refresh? It's possible that access to contacts was more severely restricted in earlier beta versions, although I haven't seen any bugs abo...

Exception when deleting pointer in a struct
I have a program with a structure object that looks like this: typedef struct _MyStruct { CString Name; CString Path; CMyObj *pObj; HINSTANCE hModule; }MyStruct; I then initialize it as below: func() { MyStruct item; item.pObj = new CMyObj(); item.Name = _T("Some Name"); item.Path = _T("Some Path"); item.hModule = AfxLoadLibrary(_T("Mylib.dll")); if (!VerifySomething()) { //unload and cleanup delete item.pObj; //Exception occurs here AfxFreeLibrary(item.hModule); } } But, when I do the &...

Throws error on Outlook shutdown
Hi, I have 3 Add-In installed for Outlook which are developed in C#. When I follow a particular sequence by using these add-ins, I am getting error on Outlook shutdown. Please refer the following log errors, 005-10-13T08:29:45.858Z INFO GOSH CExecutor.DispatchEvent result is ABORT 2005-10-13T08:29:57.123Z INFO GOSH CExecutor.DispatchEvent result is FALSE 2005-10-13T08:29:57.139Z TRACE GOSH Shutdown GOSH framework OK 2005-10-13T08:29:57.733Z ERROR GOSH Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object. at System.Drawing.SafeNativeMeth...

Out Of Office Exception
I want to setup an OOO and I thought there was a line of code or a switch you put at the bottom of your OOO message to send to outside SMTP's along with all the users in the network GAL. Something like: ***Out Of Office Exception*** Any help on this would be great. Thanks in advance. Benjamin Kirby <BKirby8677@sbcglobal.net> wrote: > I want to setup an OOO and I thought there was a line of > code or a switch you put at the bottom of your OOO > message to send to outside SMTP's along with all the > users in the network GAL. The Exchange administrators can en...

CTime.GetDay() unhandled exception
Hi, I'm not clear on how to use the CTime class correctly i use CTime o_Time; int n_Day = o_Time.GetDay (); i get an unhandled exception. What i want is to produce CString (s) 1) containing day-month-year 2) containing the current time RAN, You haven't initialised your variable. If you want the current time CTime o_Time = CTime::GetCurrentTime(); will do it. The easiest way to get a CString from this is to use CTime's own Format method CString cs = o_Time.Format("%d %B %Y"); will give you the date, eg "9 August 2007" and CString cs = o_Time.Format(&qu...