473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
(FormatException 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 1471
"Joris Zwaenepoel" <Jo*************@discussions.microsoft.com> wrote in
message news:BA**********************************@microsof t.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
(FormatException 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.microsoft.com> schreef in
bericht news:BA**********************************@microsof t.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
(FormatException 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
"ArgumentOutOfRangeException" or "ArgumentException" or even
"FormatException" from my own class libraries?

I understand that I can create custom exception types, derived from
ApplicationException, 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
ArgumentNullException?

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.microsoft.comschree f in
bericht news:5F**********************************@microsof t.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
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() {...
9
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...
5
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...
0
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...
2
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...
4
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...
7
by: iKiLL | last post by:
Hi all I am still pretty new to .Net and C#. I have come from a VB6 Background.
9
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...
7
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...

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.