catch{} butterfingers {}

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Morris

    catch{} butterfingers {}

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

    protected void ArticleFormView _ItemUpdating(o bject sender,
    FormViewUpdateE ventArgs e)
    {
    try
    {
    //Next line is line 36
    if (!ArticleDataSo urce.IsValidNew Values(e.Keys, e.NewValues))
    e.Cancel = true;
    }
    catch (FormatExceptio n)
    {
    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 ArticleDataSour ce.IsValidNewVa lues 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.FormatEx ception: Input string was not in a correct
    format.

    Source Error:

    Line 34: try
    Line 35: {
    Line 36: if (!ArticleDataSo urce.IsValidNew Values(e.Keys, e.NewValues))
    Line 37: e.Cancel = true;
    Line 38: }


    Source File:
    C:\OtherData\Ca pableObjects\do cs\QuickStart\V S2005\SourceCod e\07\QuickStart .Asp\Members\Ed itArticle.aspx. cs
    Line: 36

    Stack Trace:

    [FormatException : Input string was not in a correct format.]
    System.Number.S tringToNumber(S tring str, NumberStyles options,
    NumberBuffer& number, NumberFormatInf o info, Boolean parseDecimal) +2755599
    System.Number.P arseDecimal(Str ing value, NumberStyles options,
    NumberFormatInf o numfmt) +138
    System.Decimal. Parse(String s, NumberStyles style, IFormatProvider
    provider) +37
    System.Componen tModel.DecimalC onverter.FromSt ring(String value,
    NumberFormatInf o formatInfo) +36
    System.Componen tModel.BaseNumb erConverter.Con vertFrom(ITypeD escriptorContex t
    context, CultureInfo culture, Object value) +335

    [Exception: 2.5sd is not a valid value for Decimal.]
    System.Componen tModel.BaseNumb erConverter.Con vertFrom(ITypeD escriptorContex t
    context, CultureInfo culture, Object value) +398
    System.Componen tModel.TypeConv erter.ConvertFr om(Object value) +54
    Eco.Web.UI.WebC ontrols.EcoData SourceView.Appl yValues(IObject Instance obj,
    IDictionary values) in
    c:\dev\fbuild\s ource\Public.CL R\Handles\Asp\E coDataSourceVie w.cs:780
    Eco.Web.UI.WebC ontrols.EcoData SourceView.IsVa lidNewValues(ID ictionary
    keys, IDictionary values) in
    c:\dev\fbuild\s ource\Public.CL R\Handles\Asp\E coDataSourceVie w.cs:750
    Eco.Web.UI.WebC ontrols.EcoData Source.IsValidN ewValues(IDicti onary keys,
    IDictionary values) in
    c:\dev\fbuild\s ource\Public.CL R\Handles\Asp\E coDataSource.cs :892
    QuickStart.Edit Article.Article FormView_ItemUp dating(Object sender,
    FormViewUpdateE ventArgs e) in
    C:\OtherData\Ca pableObjects\do cs\QuickStart\V S2005\SourceCod e\07\QuickStart .Asp\Members\Ed itArticle.aspx. cs:36


  • Peter Morris

    #2
    Re: catch{} butterfingers {}

    First System.FormatEx ception is thrown. Then it appears that this is caught
    and thrown as an InnerException of a System.Exceptio n (what a poor choice).

    So I have
    System.Exceptio n
    InnerException = System.FormatEx ception

    The ASPX shows the inner exception (FormatExceptio n) so

    catch (FormatExceptio n)

    will not catch it, I need

    catch
    {
    ...etc...
    }


    Not impressed :-)


    Comment

    Working...