This project is read-only.
1
Vote

Exception thrown in TryParse

description

When using Reference.TryParse() without passing in a book name (eg. "3:16"), an exception is thrown and passed out of the TryParse method. This method should never allow a exception to be thrown, rather, it should return false.

comments

torque wrote Jun 12, 2013 at 8:31 PM

I have this issue when i put in a bogus book name. NullReferenceException, Ln 27 of Range.cs because result.Start is null from the Verse.Create. I'm not sure why it doesn't bubble up though.

torque wrote Jun 12, 2013 at 10:58 PM

In Range.cs
             result.Offset = offset;
Add a comment to this line
 
             result.Start = Verse.Create(scriptureInfo, range.FirstBook, range.FirstChapter, range.FirstVerse, range.FirstVerseSuffix, VersePosition.First, mode);
+            if (result.Start == null) return result;
+            
             result.End = Verse.Create(scriptureInfo, range.SecondBook, range.SecondChapter, range.SecondVerse, range.SecondVerseSuffix, VersePosition.Last, mode);
+            if (result.End == null) return result;
 
             int firstChapterLimitsOffset = 1 - result.Start.VerseNumber;
In Reference.cs
                     result = Create(scriptureInfo, ranges);
                 }
-                return true;
+                return (result != null && result.Count() > 0);
             }
Add a comment to this line
             catch
             {

wrote Fri at 10:20 AM