473,473 Members | 1,581 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I re-throw an exception back to the debugger?

BeemerBiker
87 New Member
I am trying my hand at throwing custom exceptions. Unfortunately, while my code to catch them does work, all the other exceptions go thru my exception handler. How do I let the exception continue on so that the VS debugger stops at the line of code that caused the problen and not in my custom catch routine which is only looking for a few things?

Expand|Select|Wrap|Line Numbers
  1.             try
  2.             {
  3.                 SolveProblem();
  4.             }
  5.             catch (Exception e)
  6.             {
  7.                 if (e.Message == "Completed")
  8.                 {
  9.                     Environment.Exit(0);
  10.                 }
  11.                 else throw (new (WhateverWorksGoesHere));
  12.             }
  13.  
I tried IOException but that didnt work. I want the VS debugger to handle all exceptions like it normally does and not stop in my above code with the message "Exception Unhandled"

I did spend some time googleing this but there was too much googlenoise.

Thanks for looking!
Oct 7 '10 #1
7 1879
Joseph Martell
198 Recognized Expert New Member
You can throw the same exception that you caught. Basically:

Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3.     SolveProblem();
  4. }
  5. catch (Exception e)
  6. {
  7.     if (e.Message == "Completed")
  8.     {
  9.         Environment.Exit(0);
  10.     }
  11.     else
  12.         throw e;
  13. }
Oct 7 '10 #2
Christian Binder
218 Recognized Expert New Member
Look at Visual Studio menu Debug and Exceptions.
There you can set, that the debugger stops even when the exceptions are handled (and you can choose at which exceptions you want your debugger to stop).
Oct 7 '10 #3
BeemerBiker
87 New Member
Didnt work worth a hoot, got a null reference as shown



After commenting out my custom throw-catch, I got the following useful stuff

Oct 8 '10 #4
peochei
12 New Member
Did you check "Thrown" checkbox for whole "Common Language Runtime Exceptions"?
Oct 8 '10 #5
Christian Binder
218 Recognized Expert New Member
I know what you're looking for.
As I told you in my previous post, did you set the debugger to stop on a NullReferenceException? Maybe you missed to select this option.

Maybe there are two check-boxes to select for NullReferenceException (that' beneath Common Language Runtime Exceptions / System, you have to select "Thrown" or something like this in Debug--Exceptions menu.

This should do exactly what you want to do.
Oct 8 '10 #6
BeemerBiker
87 New Member
I changed the exceptions as suggested, but then had a problem with XML Serialization as shown below. Googleing I see where this may be a bug with VS2008.

With exceptions thrown, the serializer fails to work as shown here



With exceptions turned off, the serializer runs ok.



There is probably one exception that is thrown that should not be thrown. I will go thru the list and find which one it is to allow the serializer to run.
Oct 17 '10 #7
Christian Binder
218 Recognized Expert New Member
There might be an exeption thrown within the .net-framework. But you can step over it when it shows up. Alternatively you can disable this exeptions in the Exceptions-Dialog. Just search for BindingFailure.
Also I don't think, it's necessary to have all exceptions enabled, I just check Common Language Runtime Exceptions when I need it, because the other exception-types are very rare.
Oct 18 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
3
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with...
2
by: sky2070 | last post by:
i have two file with jobapp.html calling jobapp_action.php <HTML> <!-- jobapp.html --> <BODY> <H1>Phop's Bicycles Job Application</H1> <P>Are you looking for an exciting career in the world of...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.