I am sometimes getting an error with uCommentsy and this in my error log:
2014-09-05 14:06:39,030 [8] INFO umbraco.BusinessLogic.Log - [Thread
23] Redirected log call (please use Umbraco.Core.Logging.LogHelper
instead of umbraco.BusinessLogic.Log) | Type: Error | User: 0 |
NodeId: 12954 | Comment: String was not recognized as a valid
DateTime. at System.DateTimeParse.Parse(String s,
DateTimeFormatInfo dtfi, DateTimeStyles styles) at
System.DateTime.Parse(String s, IFormatProvider provider) at
uCommentsy.BusinessLogic.Models.Subscription..ctor(Member member,
String[] items) in
c:\Users\Nick\Desktop\anthonydotnet-ucommentsy-ac4be9e4b684\anthonydotnet-ucommentsy-ac4be9e4b684\Source\uCommentsy.BusinessLogic\Models\Subscription.cs:line
45 at
uCommentsy.BusinessLogic.Extensions.MemberExtensions.<>c__DisplayClass3.
Notice in the catch block you parse the date using the current culture. Sometimes the DateTime.Parse function can get confused with things like the order of the days/months/years. I recommend you store dates in something like this format: http://en.wikipedia.org/wiki/ISO_8601
And you can parse dates using DateTime.ParseExact rather than DateTime.Parse. Also, might want to add an extra try block around that second parse and figure out some behavior that should take place if the date could not be parsed.
By the way, I think the error log is showing a path to code on my desktop because I had to recompile uCommentsy to work with Umbraco 7. In case the above error log text is hard to read, here's a screenshot of the error log:
Yeah, I only saw it a few times. Went away when I deleted all comment nodes under the page I was trying to post to and emptied my recycle bin.
No, it's a single-country site. Though, there's no guarantee that all the servers it's been run on will use the same date format (we have dev machines, a staging server, and a production server). I'm thinking the date format should not care about the machine the website runs on.
Rare Date Parse Error When Submitting Comment
I am sometimes getting an error with uCommentsy and this in my error log:
The problem seems to be in the Subscriptions constructor when you parse a date: https://bitbucket.org/anthonydotnet/ucommentsy/src/ac4be9e4b68428419fae78c20af514a6e0362b65/Source/uCommentsy.BusinessLogic/Models/Subscription.cs?at=default#cl-45
Notice in the catch block you parse the date using the current culture. Sometimes the DateTime.Parse function can get confused with things like the order of the days/months/years. I recommend you store dates in something like this format: http://en.wikipedia.org/wiki/ISO_8601
And you can parse dates using DateTime.ParseExact rather than DateTime.Parse. Also, might want to add an extra try block around that second parse and figure out some behavior that should take place if the date could not be parsed.
By the way, I think the error log is showing a path to code on my desktop because I had to recompile uCommentsy to work with Umbraco 7. In case the above error log text is hard to read, here's a screenshot of the error log:
You're only sometimes getting this error?
Do you have a multi-country site? Could it be different date formats?
Yeah, I only saw it a few times. Went away when I deleted all comment nodes under the page I was trying to post to and emptied my recycle bin.
No, it's a single-country site. Though, there's no guarantee that all the servers it's been run on will use the same date format (we have dev machines, a staging server, and a production server). I'm thinking the date format should not care about the machine the website runs on.
Strange.
If it happens again, and you can replicate it, please let me know.
is working on a reply...