diff --git a/libcorpus2/exception.cpp b/libcorpus2/exception.cpp index 3e0a49ab6cdc9255be05a14da3394f4f52648a43..96e7448a8da167d1d1b83f3b2450571d8dd341be 100644 --- a/libcorpus2/exception.cpp +++ b/libcorpus2/exception.cpp @@ -3,18 +3,18 @@ #include <libcorpus2/util/settings.h> namespace Corpus2 { - Error::Error(const std::string &what) - : PwrNlp::Error(what) + Corpus2Error::Corpus2Error(const std::string &what) + : PwrNlp::PwrNlpError(what) { } - Error::~Error() throw() + Corpus2Error::~Corpus2Error() throw() { } FileNotFound::FileNotFound(const std::string& filename, const std::string& paths, const std::string& where) - : Error("File not found: " + filename), filename(filename), + : Corpus2Error("File not found: " + filename), filename(filename), paths(paths), where(where) { } diff --git a/libcorpus2/exception.h b/libcorpus2/exception.h index e8f221e51519bfcbb767d57523bd27db47636dc7..ab443b7d956a1923a7923dfbfab93979583aef3e 100644 --- a/libcorpus2/exception.h +++ b/libcorpus2/exception.h @@ -10,19 +10,19 @@ namespace Corpus2 { * @c PwrNlp::Error. Call member function @c what to get a * human-readable message associated with the error. */ -class Error : public PwrNlp::Error +class Corpus2Error : public PwrNlp::PwrNlpError { public: /** * Instantiate an Error instance with the given message. * @param what The message to associate with this error. */ - Error(const std::string &what); + Corpus2Error(const std::string &what); - ~Error() throw(); + ~Corpus2Error() throw(); }; -class FileNotFound : public Error +class FileNotFound : public Corpus2Error { public: FileNotFound(const std::string& filename, const std::string& paths, diff --git a/libcorpus2/io/xces.cpp b/libcorpus2/io/xces.cpp index a951532ca391efb9f98888ac8f8ecf13abb14d39..a47e3f2714f2fc8bd5666884da4659a0ed21a252 100644 --- a/libcorpus2/io/xces.cpp +++ b/libcorpus2/io/xces.cpp @@ -11,7 +11,7 @@ namespace Corpus2 { XcesError::XcesError(const std::string &what) - : Error(what) + : Corpus2Error(what) { } diff --git a/libcorpus2/io/xces.h b/libcorpus2/io/xces.h index 70187e34bc66acd7790aa3f0073b5baec684309d..0a4f6cc2cb748acfc4ae8484fbafdb7541e7918b 100644 --- a/libcorpus2/io/xces.h +++ b/libcorpus2/io/xces.h @@ -6,7 +6,7 @@ namespace Corpus2 { -class XcesError : public Error +class XcesError : public Corpus2Error { public: /// Constructor diff --git a/libcorpus2/tagset.cpp b/libcorpus2/tagset.cpp index 3da6172d0de537da7198e96f5319605d6717f5ae..dd193b397e6061e29f6bb75cf3427b141d58cf06 100644 --- a/libcorpus2/tagset.cpp +++ b/libcorpus2/tagset.cpp @@ -21,7 +21,7 @@ namespace Corpus2 { TagParseError::TagParseError(const std::string &what, const std::string& val, const std::string& tag, const std::string& tagset) - : Error(what), val(val), tag(tag), tagset(tagset) + : Corpus2Error(what), val(val), tag(tag), tagset(tagset) { } @@ -43,14 +43,14 @@ std::string TagParseError::info() const TagsetMismatch::TagsetMismatch(const std::string& where, const Tagset& expected, const Tagset& actual) - : Error("Tagset mismatch in " + where), expected_id(expected.id()) + : Corpus2Error("Tagset mismatch in " + where), expected_id(expected.id()) , actual_id(actual.id()) { } TagsetMismatch::TagsetMismatch(const std::string& where, tagset_idx_t expected, tagset_idx_t actual) - : Error("Tagset mismatch in " + where), expected_id(expected) + : Corpus2Error("Tagset mismatch in " + where), expected_id(expected) , actual_id(actual) { } @@ -382,7 +382,7 @@ attribute_idx_t Tagset::get_value_attribute(value_idx_t id) const if (!value_dict_.is_id_valid(id)) { std::stringstream ss; ss << "get_value_attribute fail " << (int)id; - throw Error(ss.str()); + throw Corpus2Error(ss.str()); } return value_attribute_[id]; } diff --git a/libcorpus2/tagset.h b/libcorpus2/tagset.h index 17b2bc895188d3906707635151bf2d477bb1b7c7..1a845d83df9cb2c2819393be73bf301f5690aa21 100644 --- a/libcorpus2/tagset.h +++ b/libcorpus2/tagset.h @@ -21,7 +21,7 @@ namespace Corpus2 { /** * Exception class for signalling tag parse errors */ -class TagParseError : public Error +class TagParseError : public Corpus2Error { public: /// Constructor @@ -38,7 +38,7 @@ public: }; /// Exception class for signalling tagset mismatches in various situations -class TagsetMismatch : public Error +class TagsetMismatch : public Corpus2Error { public: /// Constructor from Tagset objects diff --git a/libcorpus2/tagsetmanager.cpp b/libcorpus2/tagsetmanager.cpp index 02f6ac3ad698dcbbecd9807ab19da8128c430d91..a9a02fc5c8d38f600c0c6812016bb9a0b638afb7 100644 --- a/libcorpus2/tagsetmanager.cpp +++ b/libcorpus2/tagsetmanager.cpp @@ -9,7 +9,7 @@ namespace Corpus2 { TagsetNotFound::TagsetNotFound(tagset_idx_t id) - : Error("Tagset not found") + : Corpus2Error("Tagset not found") , id(id) { } diff --git a/libcorpus2/tagsetmanager.h b/libcorpus2/tagsetmanager.h index 43ca9e365678c1427606fac6dd5b71d7d3be8843..fb0f6e95310c2b5dee5f7bf6c584c34cd0c02138 100644 --- a/libcorpus2/tagsetmanager.h +++ b/libcorpus2/tagsetmanager.h @@ -12,7 +12,7 @@ namespace Corpus2 { /** * Exception class for signalling cache errors */ -class TagsetNotFound : public Error +class TagsetNotFound : public Corpus2Error { public: /// Constructor diff --git a/libcorpus2/tagsetparser.h b/libcorpus2/tagsetparser.h index b5febb0ca9f7bcff476ee700695a9f32cf2f61d7..2d2e7adf459a8d493c173fcf8b15ee02766377a0 100644 --- a/libcorpus2/tagsetparser.h +++ b/libcorpus2/tagsetparser.h @@ -5,12 +5,12 @@ namespace Corpus2 { -class TagsetParseError : public Error +class TagsetParseError : public Corpus2Error { public: TagsetParseError(const std::string& w, int line, const std::string& data) - : Error("Tagset parse error: " + w), line(line), data(data) + : Corpus2Error("Tagset parse error: " + w), line(line), data(data) { } diff --git a/libcorpus2/token.cpp b/libcorpus2/token.cpp index 994de8b3dd48ea6508f7452c9a796572e2f2addb..f4317c51f404dece3566dc593c78cae2d7f34b09 100644 --- a/libcorpus2/token.cpp +++ b/libcorpus2/token.cpp @@ -26,7 +26,7 @@ const Lexeme& Token::get_preferred_lexeme(const Tagset& tagset) const if (idx < lexemes_.size()) { return lexemes_[idx]; } else { - throw Error("No lexemes but best lexeme requested"); + throw Corpus2Error("No lexemes but best lexeme requested"); } } diff --git a/libpwrutils/exception.cpp b/libpwrutils/exception.cpp index 35d21b936562b7118f39b6cf14b2913a8663bd16..f500c110668473d1f2f075af6dd074ec51cc63ac 100644 --- a/libpwrutils/exception.cpp +++ b/libpwrutils/exception.cpp @@ -18,16 +18,16 @@ or FITNESS FOR A PARTICULAR PURPOSE. namespace PwrNlp { -Error::Error(const std::string &what) +PwrNlpError::PwrNlpError(const std::string &what) : std::runtime_error(what) { } -Error::~Error() throw() +PwrNlpError::~PwrNlpError() throw() { } -std::string Error::info() const +std::string PwrNlpError::info() const { return what(); } diff --git a/libpwrutils/exception.h b/libpwrutils/exception.h index 9f0d99c70f6e0ada469880db7e200704e1543d5b..5ad8a4dc650151b749eed200d1e6ae1bedda7948 100644 --- a/libpwrutils/exception.h +++ b/libpwrutils/exception.h @@ -27,17 +27,17 @@ namespace PwrNlp { * associated with the error. Call member function @c info to get verbose * information about the error in possibly multi-line form. */ -class Error : public std::runtime_error +class PwrNlpError : public std::runtime_error { public: /** * Instantiate an Error instance with the given message. * @param what The message to associate with this error. */ - Error(const std::string &what); + PwrNlpError(const std::string &what); /// Destructor - ~Error() throw(); + ~PwrNlpError() throw(); /// verbose-info function virtual std::string info() const; diff --git a/tagset-tool/main.cpp b/tagset-tool/main.cpp index 97878c9106298d465a1d95a3c400dff550a4359c..553bc4db2caa43ed0efef2b60c584935a5941faa 100644 --- a/tagset-tool/main.cpp +++ b/tagset-tool/main.cpp @@ -245,7 +245,7 @@ int main(int argc, char** argv) #else std_read_loop(f); #endif - } catch (Corpus2::Error& e) { + } catch (Corpus2::Corpus2Error& e) { std::cerr << "Error: " << e.info() << "\n"; return 4; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index fa3aa8bc2a254f83057f3c00546b28f1097d8cb1..d0f1de97eafde2af57d3fe013ddda8e2e3b2b711 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable( tests tagset_parse.cpp ) -target_link_libraries ( tests maca ${Boost_LIBRARIES}) +target_link_libraries ( tests corpus2 pwrutils ${Boost_LIBRARIES}) include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIRS}) diff --git a/tests/tagset_parse.cpp b/tests/tagset_parse.cpp index 4fd78c795220a098c7c78d24102a3731a0c55940..892e072945c95a86f4654f71c7dea018803a70fe 100644 --- a/tests/tagset_parse.cpp +++ b/tests/tagset_parse.cpp @@ -130,7 +130,7 @@ BOOST_AUTO_TEST_CASE( load_named ) BOOST_CHECK_NO_THROW( try { Corpus2::get_named_tagset("test"); - }catch(Corpus2::Error& e) { + } catch (Corpus2::Corpus2Error& e) { std::cerr << e.info(); throw; }