473,396 Members | 2,129 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,396 software developers and data experts.

catch{} butterfingers {}

Hi all, I have a perplexing problem....

protected void ArticleFormView_ItemUpdating(object sender,
FormViewUpdateEventArgs e)
{
try
{
//Next line is line 36
if (!ArticleDataSource.IsValidNewValues(e.Keys, e.NewValues))
e.Cancel = true;
}
catch (FormatException)
{
e.Cancel = true;
Page.Validators.Add(new StaticValidator("Invalid price"));
}
}

As you can see I am catching FormatException. I put a breakline on line 36
and when I hit F10 ArticleDataSource.IsValidNewValues will throw a
FormatException. At this point I would expect my Catch to kick in, but as
you can see from the following exception information it is not. Does anyone
know why this is?
Thanks

Pete
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct
format.

Source Error:

Line 34: try
Line 35: {
Line 36: if (!ArticleDataSource.IsValidNewValues(e.Keys, e.NewValues))
Line 37: e.Cancel = true;
Line 38: }
Source File:
C:\OtherData\CapableObjects\docs\QuickStart\VS2005 \SourceCode\07\QuickStart.Asp\Members\EditArticle. aspx.cs
Line: 36

Stack Trace:

[FormatException: Input string was not in a correct format.]
System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +2755599
System.Number.ParseDecimal(String value, NumberStyles options,
NumberFormatInfo numfmt) +138
System.Decimal.Parse(String s, NumberStyles style, IFormatProvider
provider) +37
System.ComponentModel.DecimalConverter.FromString( String value,
NumberFormatInfo formatInfo) +36
System.ComponentModel.BaseNumberConverter.ConvertF rom(ITypeDescriptorContext
context, CultureInfo culture, Object value) +335

[Exception: 2.5sd is not a valid value for Decimal.]
System.ComponentModel.BaseNumberConverter.ConvertF rom(ITypeDescriptorContext
context, CultureInfo culture, Object value) +398
System.ComponentModel.TypeConverter.ConvertFrom(Ob ject value) +54
Eco.Web.UI.WebControls.EcoDataSourceView.ApplyValu es(IObjectInstance obj,
IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDat aSourceView.cs:780
Eco.Web.UI.WebControls.EcoDataSourceView.IsValidNe wValues(IDictionary
keys, IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDat aSourceView.cs:750
Eco.Web.UI.WebControls.EcoDataSource.IsValidNewVal ues(IDictionary keys,
IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDat aSource.cs:892
QuickStart.EditArticle.ArticleFormView_ItemUpdatin g(Object sender,
FormViewUpdateEventArgs e) in
C:\OtherData\CapableObjects\docs\QuickStart\VS2005 \SourceCode\07\QuickStart.Asp\Members\EditArticle. aspx.cs:36
Mar 13 '08 #1
1 1340
First System.FormatException is thrown. Then it appears that this is caught
and thrown as an InnerException of a System.Exception (what a poor choice).

So I have
System.Exception
InnerException = System.FormatException

The ASPX shows the inner exception (FormatException) so

catch (FormatException)

will not catch it, I need

catch
{
...etc...
}
Not impressed :-)
Mar 13 '08 #2

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

Similar topics

10
by: Gary.Hu | last post by:
I was trying to catch the Arithmetic exception, unsuccessfully. try{ int a = 0, b = 9; b = b / a; }catch(...){ cout << "arithmetic exception was catched!" << endl; } After ran the program,...
11
by: kaeli | last post by:
Hey all, I'd like to start using the try/catch construct in some scripts. Older browsers don't support this. What's the best way to test for support for this construct so it doesn't kill...
4
by: Abhishek Srivastava | last post by:
Hello All, I have seen code snippets like try { ..... } catch {
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
13
by: Benny | last post by:
Hi, I have something like this: try { // some code } catch // note - i am catching everything now {
23
by: VB Programmer | last post by:
Variable scope doesn't make sense to me when it comes to Try Catch Finally. Example: In order to close/dispose a db connection you have to dim the connection outside of the Try Catch Finally...
2
by: Ralph Krausse | last post by:
I created a try/catch/finally but when an expection is thrown, the catch does not handle it... (I know this code is wrong, I want to force the error for this example) try { DataSet ds = new...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...

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.