From 8b95516aef0cd4bd98e2592d6f247882dc88886a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 31 Mar 2018 23:11:20 -0400 Subject: Converted asserts in generator to exceptions --- generator/word.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'generator/word.h') diff --git a/generator/word.h b/generator/word.h index 2e469d4..2818202 100644 --- a/generator/word.h +++ b/generator/word.h @@ -1,7 +1,7 @@ #ifndef WORD_H_91F99D46 #define WORD_H_91F99D46 -#include +#include #include #include "../lib/enums.h" @@ -61,8 +61,10 @@ namespace verbly { int getTagCount() const { - // Calling code should always call hasTagCount first. - assert(hasTagCount_); + if (!hasTagCount_) + { + throw std::domain_error("Word does not have a tag count"); + } return tagCount_; } @@ -79,8 +81,10 @@ namespace verbly { const group& getVerbGroup() const { - // Calling code should always call hasVerbGroup first. - assert(verbGroup_ != nullptr); + if (!hasVerbGroup()) + { + throw std::domain_error("Word does not have a verb group"); + } return *verbGroup_; } -- cgit 1.4.1