This is a migrated thread and some comments may be shown as answers.

RecurrenceRule.TryParse -- throwing exceptions

3 Answers 98 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 15 Apr 2014, 04:45 PM
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.

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 18 Apr 2014, 08:58 AM
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.

 
0
Richard
Top achievements
Rank 1
answered on 18 Apr 2014, 05:11 PM
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.
0
Plamen
Telerik team
answered on 21 Apr 2014, 11:55 AM
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.

 
Tags
Scheduler
Asked by
Richard
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Richard
Top achievements
Rank 1
Share this question
or