handling more errors gracefully
This commit is contained in:
parent
4ff4693fa3
commit
b75a672ce2
|
@ -45,8 +45,11 @@
|
||||||
public Story ParseBlocks(IEnumerable<Block> blocks)
|
public Story ParseBlocks(IEnumerable<Block> blocks)
|
||||||
{
|
{
|
||||||
// get the story
|
// get the story
|
||||||
var storyBlock = blocks.SingleOrDefault(b => b.Type == BlockType.Story);
|
var storyBlocks = blocks.Where(b => b.Type == BlockType.Story);
|
||||||
if(storyBlock == null) throw new FicdownException("No story block found");
|
if(storyBlocks.Count() == 0) throw new FicdownException("No story block found");
|
||||||
|
if(storyBlocks.Count() > 1) throw new FicdownException("More than one story block found");
|
||||||
|
|
||||||
|
var storyBlock = storyBlocks.Single();
|
||||||
|
|
||||||
Anchor storyAnchor;
|
Anchor storyAnchor;
|
||||||
try
|
try
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var scene = _story.Scenes[_story.FirstScene].Where(s => s.Conditions == null);
|
var scene = _story.Scenes[_story.FirstScene].Where(s => s.Conditions == null);
|
||||||
if(scene == null)
|
if(scene.Count() == 0)
|
||||||
throw new FicdownException(_story.Name, string.Format("Story links to undefined scene: {0}", _story.FirstScene));
|
throw new FicdownException(_story.Name, string.Format("Story links to undefined scene: {0}", _story.FirstScene));
|
||||||
if(scene.Count() > 1)
|
if(scene.Count() > 1)
|
||||||
throw new FicdownException(_story.Name, string.Format("Story links to scene that is defined more than once: {0}", _story.FirstScene));
|
throw new FicdownException(_story.Name, string.Format("Story links to scene that is defined more than once: {0}", _story.FirstScene));
|
||||||
|
|
Loading…
Reference in New Issue