diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-31 23:11:20 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-03-31 23:11:20 -0400 |
| commit | 8b95516aef0cd4bd98e2592d6f247882dc88886a (patch) | |
| tree | 27d13676d0fbe075c9eb576037c9a117769533e3 /generator/word.h | |
| parent | 75e947fa0021547f460496d1c3aef5b61af4c669 (diff) | |
| download | verbly-8b95516aef0cd4bd98e2592d6f247882dc88886a.tar.gz verbly-8b95516aef0cd4bd98e2592d6f247882dc88886a.tar.bz2 verbly-8b95516aef0cd4bd98e2592d6f247882dc88886a.zip | |
Converted asserts in generator to exceptions
Diffstat (limited to 'generator/word.h')
| -rw-r--r-- | generator/word.h | 14 |
1 files changed, 9 insertions, 5 deletions
| 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 @@ | |||
| 1 | #ifndef WORD_H_91F99D46 | 1 | #ifndef WORD_H_91F99D46 |
| 2 | #define WORD_H_91F99D46 | 2 | #define WORD_H_91F99D46 |
| 3 | 3 | ||
| 4 | #include <cassert> | 4 | #include <stdexcept> |
| 5 | #include <hkutil/database.h> | 5 | #include <hkutil/database.h> |
| 6 | #include "../lib/enums.h" | 6 | #include "../lib/enums.h" |
| 7 | 7 | ||
| @@ -61,8 +61,10 @@ namespace verbly { | |||
| 61 | 61 | ||
| 62 | int getTagCount() const | 62 | int getTagCount() const |
| 63 | { | 63 | { |
| 64 | // Calling code should always call hasTagCount first. | 64 | if (!hasTagCount_) |
| 65 | assert(hasTagCount_); | 65 | { |
| 66 | throw std::domain_error("Word does not have a tag count"); | ||
| 67 | } | ||
| 66 | 68 | ||
| 67 | return tagCount_; | 69 | return tagCount_; |
| 68 | } | 70 | } |
| @@ -79,8 +81,10 @@ namespace verbly { | |||
| 79 | 81 | ||
| 80 | const group& getVerbGroup() const | 82 | const group& getVerbGroup() const |
| 81 | { | 83 | { |
| 82 | // Calling code should always call hasVerbGroup first. | 84 | if (!hasVerbGroup()) |
| 83 | assert(verbGroup_ != nullptr); | 85 | { |
| 86 | throw std::domain_error("Word does not have a verb group"); | ||
| 87 | } | ||
| 84 | 88 | ||
| 85 | return *verbGroup_; | 89 | return *verbGroup_; |
| 86 | } | 90 | } |
