473,569 Members | 3,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Break when the exception is thrown and IsNumeric

Hi all,

I don't think a solution exists, but maybe there is some option in Visual
Studio that I do not know about.

When developping (or debugging), I like to set the "exceptions " option to
"break when the error is thrown", even for handled exceptions, because a
general purpose error handler usually handles all unexpected exceptions.

A side effect of that is that a break also happens when an exception occurs
inside a function that is not in my code, for example when the IsNumeric
function is called with an argument that is not numeric, or when IsDate is
called when an argument that is not a date.

If someone would know how to avoid this, then I would appreciate it if you
could share it here. I know I can modify the setting for each exception type
(FormatExceptio n in case of the IsNumeric function), but I don't want to do
that, because that also would change the behaviour of those exception when
resulting from my own code.

Thanks in advance,

Joris
Jun 30 '06 #1
5 1482
"Joris Zwaenepoel" <Jo************ *@discussions.m icrosoft.com> wrote in
message news:BA******** *************** ***********@mic rosoft.com...
Hi all,

I don't think a solution exists, but maybe there is some option in Visual
Studio that I do not know about.

When developping (or debugging), I like to set the "exceptions " option to
"break when the error is thrown", even for handled exceptions, because a
general purpose error handler usually handles all unexpected exceptions.

A side effect of that is that a break also happens when an exception
occurs
inside a function that is not in my code, for example when the IsNumeric
function is called with an argument that is not numeric, or when IsDate is
called when an argument that is not a date.

If someone would know how to avoid this, then I would appreciate it if you
could share it here. I know I can modify the setting for each exception
type
(FormatExceptio n in case of the IsNumeric function), but I don't want to
do
that, because that also would change the behaviour of those exception when
resulting from my own code.


You should not be throwing system exceptions from within your own code. You
should be throwing application exceptions from within your code. If you fix
your own mistake first, you will have no problem avoiding the behavior that
you dislike in Visual Studio.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Jun 30 '06 #2
Joris,

You can catch those errors by setting this in the debug options. You can
fine tune this setting depending on your own need.

In version 2002/2003 you find this information in
Debug -> Exceptions

In version 2005 I don't know where they have hide it, but you can get it in
the project with
ctrl alt E

I hope this helps,

Cor
"Joris Zwaenepoel" <Jo************ *@discussions.m icrosoft.com> schreef in
bericht news:BA******** *************** ***********@mic rosoft.com...
Hi all,

I don't think a solution exists, but maybe there is some option in Visual
Studio that I do not know about.

When developping (or debugging), I like to set the "exceptions " option to
"break when the error is thrown", even for handled exceptions, because a
general purpose error handler usually handles all unexpected exceptions.

A side effect of that is that a break also happens when an exception
occurs
inside a function that is not in my code, for example when the IsNumeric
function is called with an argument that is not numeric, or when IsDate is
called when an argument that is not a date.

If someone would know how to avoid this, then I would appreciate it if you
could share it here. I know I can modify the setting for each exception
type
(FormatExceptio n in case of the IsNumeric function), but I don't want to
do
that, because that also would change the behaviour of those exception when
resulting from my own code.

Thanks in advance,

Joris

Jun 30 '06 #3
Nick,

Do you mean that I should not throw exception types like
"ArgumentOutOfR angeException" or "ArgumentExcept ion" or even
"FormatExceptio n" from my own class libraries?

I understand that I can create custom exception types, derived from
ApplicationExce ption, but I do not understand why throwing one of these
framework exception types would be a mistake. For example, if an argument is
passed with a value of null (or Nothing), what is wrong with throwing an
ArgumentNullExc eption?

Joris
"Nick Malik [Microsoft]" wrote:
>
You should not be throwing system exceptions from within your own code. You
should be throwing application exceptions from within your code. If you fix
your own mistake first, you will have no problem avoiding the behavior that
you dislike in Visual Studio.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
Jul 4 '06 #4
Cor,

Thanks for trying to help. I know where to fine-tune the settings, but what
I really want is that the break only happens when the error is thrown and
bubbles up to the my code that calls that procedure.

I don't care if IsNumeric and IsDate use an exception in their
implementation, I use it because those function to validate data. I can
disable the "break when the exception is thrown" setting for those exception
types, but then this is disabled also when the same exception type is not
handled inside the called procedure but because of my own exception handling
logic.

I hope my explanation is clear, if not, I can try to create a small
code-example.

I don't think it is possible in VS2003, and probably not in VS2005 either,
but there are more options available that I don't know of, and I was hoping
that would be the case here.

Joris

"Cor Ligthert [MVP]" wrote:
Joris,

You can catch those errors by setting this in the debug options. You can
fine tune this setting depending on your own need.

In version 2002/2003 you find this information in
Debug -Exceptions

In version 2005 I don't know where they have hide it, but you can get it in
the project with
ctrl alt E

I hope this helps,

Cor

Jul 5 '06 #5
Joris,

Did you try those debug options, they can (need to) be very much fine tuned.

Cor

"Joris Zwaenepoel" <Jo************ *@discussions.m icrosoft.comsch reef in
bericht news:5F******** *************** ***********@mic rosoft.com...
Cor,

Thanks for trying to help. I know where to fine-tune the settings, but
what
I really want is that the break only happens when the error is thrown and
bubbles up to the my code that calls that procedure.

I don't care if IsNumeric and IsDate use an exception in their
implementation, I use it because those function to validate data. I can
disable the "break when the exception is thrown" setting for those
exception
types, but then this is disabled also when the same exception type is not
handled inside the called procedure but because of my own exception
handling
logic.

I hope my explanation is clear, if not, I can try to create a small
code-example.

I don't think it is possible in VS2003, and probably not in VS2005 either,
but there are more options available that I don't know of, and I was
hoping
that would be the case here.

Joris

"Cor Ligthert [MVP]" wrote:
>Joris,

You can catch those errors by setting this in the debug options. You can
fine tune this setting depending on your own need.

In version 2002/2003 you find this information in
Debug -Exceptions

In version 2005 I don't know where they have hide it, but you can get it
in
the project with
ctrl alt E

I hope this helps,

Cor


Jul 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6741
by: n_o_s_p_a__m | last post by:
Can't compile. Does this mean that all functions that throw exceptions must be of return type void? examples: // won't compile: "not all code paths return a value" public override int Run() { throw new Exception("exception thrown"); }
9
13176
by: Bill Borg | last post by:
Hello, I call a function recursively to find an item that exists *anywhere* down the chain. Let's say I find it five layers deep. Now I've got what I need and want to break out of that whole stack and continue execution at the point of the initial call. Is that possible? Thanks, Bill
5
3288
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can view it in one of the windows (autos or locals, don't remember which). That doesn't appear to be the case with vb.net. I also tried using the...
0
971
by: Jon | last post by:
I have a reproducible problem. In my application I have handlers for both the AppDomain.CurrentDomain.UnhandledException event and the Applciation.ThreadException events. Up until now these seemed to be catching all of the unhandled errors in my application. However, it appears that if an exception is thrown in certain UserControl subs that...
2
1910
by: CodeSlayer | last post by:
Hi all, This one really has me and the other .Net developers at my work stumped. I have an application that is doing the following: 1 - attempt to validate that user can create a windows task via COM interops 2 - an exception is thrown because user doesn't exist 3 - Exception is caught by calling code shown below:
4
3044
by: escristian | last post by:
Hello. I'm trying to create an Image so I use something like this: Image newImage = Image.FromFile(filename); Now when it's a bmp file and certain .gif files it gives me an exception that says: "Invalid parameter used". The gif an bmp files are valid image files, I can open them in any graphics software and windows can do the preview.
7
6562
by: iKiLL | last post by:
Hi all I am still pretty new to .Net and C#. I have come from a VB6 Background.
9
1923
by: =?Utf-8?B?UmFq?= | last post by:
How do I know which methods will throw exception when I am using FCL or other third party .Net library? I am developer of mostly native Windows applications and now .Net. After working few months in Java, I am thinking why Win32 APIs or even .Net documentation not clear on which methods will throw exception or what exceptions can be...
7
6439
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, misters, I have Windows App .net 2.0 + vs 2005. My form launch several MSI's (app1.msi, app2.msi). I try launch MSI using Process.Start. I need know when detect MSI executable has finished ? Perphaps, I launch MSI and wait it until finish.
0
7703
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...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
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...
1
7681
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3662
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...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.