RecurrenceRule.TryParse -- throwing exceptions

4 posts, 0 answers
  1. Richard
    Richard avatar
    2 posts
    Member since:
    Dec 2012

    Posted 15 Apr 2014 Link to this post

    We've found some cases where calling RecurrenceRule.TryParse ends up throwing an exception.
    //in namespace Telerik.Web.UI
    RecurrenceRule blah;
    RecurrenceRule.TryParse("DTSTART:20140417T224500Z\r\nDTEND:20140417T234500Z\r\nRRULE:FREQ=YEARLY;INTERVAL=8;COUNT=1;\r\n", out blah); //exception
    RecurrenceRule.TryParse("DTSTART:20140417T224500Z\r\nDTEND:20140417T234500Z\r\nRRULE:FREQ=DAILY;INTERVAL=8;COUNT=1;\r\n", out blah); //ok
    RecurrenceRule.TryParse("DTSTART:20140417T224500Z\r\nDTEND:20140417T234500Z\r\nRRULE:FREQ=MONTHLY;INTERVAL=8;COUNT=1;\r\n", out blah); //exception
    RecurrenceRule.TryParse("DTSTART:20140417T224500Z\r\nDTEND:20140417T234500Z\r\nRRULE:FREQ=MONTHLY;INTERVAL=1;COUNT=1;\r\n", out blah); //exception
    RecurrenceRule.TryParse("DTSTART:20140417T224500Z\r\nDTEND:20140417T234500Z\r\nRRULE:FREQ=YEARLY;INTERVAL=1;COUNT=1;\r\n", out blah); //exception

    Now, we can obviously wrap these calls in try/catch blocks or try to make the strings valid, but that defeats the entire purpose of the TryParse methods.  They should return false if the string being passed in representing the datatype's value is invalid and/or not well formatted.
  2. Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 18 Apr 2014 Link to this post

    Hello Richard,

    The exceptions are caused by the fact that Monthly and Yearly recurrences in RadScheduler does not support INTERVAL property in the rule because they do not have "Every" field in the RecurrenceEditor- it is only supported in Hourly, Daily and Weekly recurrences.

    Hope this will explain the issue. If you have further questions please let me know.

    Regards,
    Plamen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard
    Richard avatar
    2 posts
    Member since:
    Dec 2012

    Posted 18 Apr 2014 Link to this post

    Storing the values in a proper format is really a side issue at this point.  My primary complaint is with the TryParse method's behavior when it gets a bad string.

    From my OP:
    "Now, we can obviously wrap these calls in try/catch blocks or try to make the strings valid, but that defeats the entire purpose of the TryParse methods.  They should return false if the string being passed in representing the datatype's value is invalid and/or not well formatted."

    There's no point in having a TryParse method at all if it's going to throw an exception when it can't parse the string into the data type.  Our only recourse at this point is to wrap this "TryParse" method in a try/catch block and use exception handling to detect validation problems, which is inefficient and a bad practice.
  5. Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 21 Apr 2014 Link to this post

    Hello,

    You are right it is a bug indeed-I have logged it for fixing. You can follow its status and vote for it here.

    Thank you very much for reporting the issue and for your concern with  Telerik UI for ASP .NET AJAX.

    Regards,
    Plamen
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top