PC Review


Reply
Thread Tools Rate Thread

catch{} butterfingers {}

 
 
Peter Morris
Guest
Posts: n/a
 
      13th Mar 2008
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.ConvertFrom(ITypeDescriptorContext
context, CultureInfo culture, Object value) +335

[Exception: 2.5sd is not a valid value for Decimal.]
System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext
context, CultureInfo culture, Object value) +398
System.ComponentModel.TypeConverter.ConvertFrom(Object value) +54
Eco.Web.UI.WebControls.EcoDataSourceView.ApplyValues(IObjectInstance obj,
IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDataSourceView.cs:780
Eco.Web.UI.WebControls.EcoDataSourceView.IsValidNewValues(IDictionary
keys, IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDataSourceView.cs:750
Eco.Web.UI.WebControls.EcoDataSource.IsValidNewValues(IDictionary keys,
IDictionary values) in
c:\dev\fbuild\source\Public.CLR\Handles\Asp\EcoDataSource.cs:892
QuickStart.EditArticle.ArticleFormView_ItemUpdating(Object sender,
FormViewUpdateEventArgs e) in
C:\OtherData\CapableObjects\docs\QuickStart\VS2005\SourceCode\07\QuickStart.Asp\Members\EditArticle.aspx.cs:36


 
Reply With Quote
 
 
 
 
Peter Morris
Guest
Posts: n/a
 
      13th Mar 2008
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 :-)


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
try..catch catch the error only running inside of VS.NET Dragos Hilbert Microsoft C# .NET 2 11th Mar 2008 03:35 PM
Difference between try{}catch{} and try{}catch(Exception e){} ? Mr Flibble Microsoft C# .NET 7 22nd Jun 2006 04:25 PM
Catch block is failing to catch exceptions when not run from MSDev CodeSlayer Microsoft C# .NET 2 16th Feb 2006 06:42 PM
try-catch won't catch in the Release mode =?Utf-8?B?bGF1Y2gy?= Microsoft VC .NET 4 15th Nov 2005 06:36 AM
Try Catch Question How Make it go to specific catch? needin4mation@gmail.com Microsoft C# .NET 3 10th Oct 2005 08:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.