473,787 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ 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 1887
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 NullReferenceEx ception? Maybe you missed to select this option.

Maybe there are two check-boxes to select for NullReferenceEx ception (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
4323
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 be better to promote better programming than rely on PHP to compensate for lazy programming?
4
6430
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 well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from the dark side of the moon"
1
4101
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 for adding so much code... <TABLE border="1" bordercolor="#000000" cellspacing="0"> <TR>
11
4012
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
18540
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 blocks until something.exe terminates. Just what I /don't/ want. (Wouldn't an & be nice here! Sigh) I need something.exe to disconnect and run in the background while I
1
3704
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 sockets??
10
4225
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
3639
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 NOT IN ( SELECT manufacturers_id FROM products )
3
3492
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 the variable $GET but $GET is not a variable, I thought it came from the page that calls the PHP file? if(($_GET)==""){ this gets an error
2
106619
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 cyclery? Look no further! </P> <FORM NAME='frmJobApp' METHOD=post ACTION="jobapp_action.php"> Please enter your name:
0
9655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
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 we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.