C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,406 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,633 people online right now. Registration is fast and FREE... Join Now!




ignore exception

 

ignore exception

izzahaf

2 Jul, 2009 - 07:12 AM
Post #1

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

hi hi

how to ignore exception?
i catch the exception , but program that i run didn't stop, i can continue running my code without get exception before it. it run normally. .confusing.
how i ignore the exception, and continue

thx

User is offlineProfile CardPM
+Quote Post


modi123_1

RE: Ignore Exception

2 Jul, 2009 - 07:16 AM
Post #2

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
QUOTE(izzahaf @ 2 Jul, 2009 - 09:12 AM) *

hi hi

how to ignore exception?
i catch the exception , but program that i run didn't stop, i can continue running my code without get exception before it. it run normally. .confusing.
how i ignore the exception, and continue

thx


What's your try/catch look like?

If you catch the exception and do not throw another it should be consumed.
User is offlineProfile CardPM
+Quote Post

izzahaf

RE: Ignore Exception

2 Jul, 2009 - 07:31 AM
Post #3

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

QUOTE(modi123_1 @ 2 Jul, 2009 - 07:16 AM) *

QUOTE(izzahaf @ 2 Jul, 2009 - 09:12 AM) *

hi hi

how to ignore exception?
i catch the exception , but program that i run didn't stop, i can continue running my code without get exception before it. it run normally. .confusing.
how i ignore the exception, and continue

thx


What's your try/catch look like?

If you catch the exception and do not throw another it should be consumed.

i have codes:
CODE

for (int i = 0; i < hi; i++)
                    weight[1][0][i] = paramDataReader.ReadElementContentAsDouble();


and the exception : ReadElementContentAs() methods cannot be called on an element that has child elements

when i click start debugging it run as usual. ph34r.gif
User is offlineProfile CardPM
+Quote Post

modi123_1

RE: Ignore Exception

2 Jul, 2009 - 08:32 AM
Post #4

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
So... you are not using a try/catch to wrap that piece of code?
User is offlineProfile CardPM
+Quote Post

izzahaf

RE: Ignore Exception

2 Jul, 2009 - 05:05 PM
Post #5

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

QUOTE(modi123_1 @ 2 Jul, 2009 - 08:32 AM) *

So... you are not using a try/catch to wrap that piece of code?


no. i want to continue next step. how ur suggestion. thanks before.


User is offlineProfile CardPM
+Quote Post

modi123_1

RE: Ignore Exception

2 Jul, 2009 - 05:52 PM
Post #6

Suiter #2
Group Icon

Joined: 12 Jun, 2008
Posts: 1,760



Thanked: 72 times
Dream Kudos: 150
My Contributions
QUOTE(izzahaf @ 2 Jul, 2009 - 07:05 PM) *

QUOTE(modi123_1 @ 2 Jul, 2009 - 08:32 AM) *

So... you are not using a try/catch to wrap that piece of code?


no. i want to continue next step. how ur suggestion. thanks before.


That's the whole point of a try/catch... you can recover from what would be a catastrophic error..
User is offlineProfile CardPM
+Quote Post

papuccino1

RE: Ignore Exception

2 Jul, 2009 - 07:03 PM
Post #7

C# Programmer
Group Icon

Joined: 2 Mar, 2008
Posts: 943



Thanked: 33 times
Dream Kudos: 50
My Contributions
I think he doesn't mean try/catch at all. I think what he's trying to say is that:

QUOTE
This code throws this exception when I run it. How can I fix this exception?


or

QUOTE
This code is not functioning as it should, but doesn't throw any exception (the program still runs)


Izza would you mind posting all the code related to this:

csharp
for (int i = 0; i < hi; i++)
weight[1][0][i] = paramDataReader.ReadElementContentAsDouble();


This post has been edited by papuccino1: 2 Jul, 2009 - 07:04 PM
User is offlineProfile CardPM
+Quote Post

izzahaf

RE: Ignore Exception

2 Jul, 2009 - 11:27 PM
Post #8

D.I.C Head
**

Joined: 12 Mar, 2009
Posts: 98

QUOTE(papuccino1 @ 2 Jul, 2009 - 07:03 PM) *

I think he doesn't mean try/catch at all. I think what he's trying to say is that:

QUOTE
This code throws this exception when I run it. How can I fix this exception?


or

QUOTE
This code is not functioning as it should, but doesn't throw any exception (the program still runs)


Izza would you mind posting all the code related to this:

csharp
for (int i = 0; i < hi; i++)
weight[1][0][i] = paramDataReader.ReadElementContentAsDouble();




the exception isn't usual i think. it stop the program but when i continue debugging it run the point of code where it catch exception and go to the next code.
so i try this :
CODE

for (int i = 0; i < hi; i++)
                    {
                        try
                        {
                             weight[1][0][i] = paramDataReader.ReadElementContentAsDouble();
                        }
                        catch {  weight[1][0][i] = paramDataReader.ReadElementContentAsDouble(); }
                    }


and it works.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 10:48PM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month