From d7eb742df3084823a195e42f4ce051aa9b17d56f Mon Sep 17 00:00:00 2001
From: ilor <kailoran@gmail.com>
Date: Wed, 22 Sep 2010 11:23:06 +0200
Subject: [PATCH] rename Error classes to avoid ambiguity

---
 libcorpus2/exception.cpp     | 8 ++++----
 libcorpus2/exception.h       | 8 ++++----
 libcorpus2/io/xces.cpp       | 2 +-
 libcorpus2/io/xces.h         | 2 +-
 libcorpus2/tagset.cpp        | 8 ++++----
 libcorpus2/tagset.h          | 4 ++--
 libcorpus2/tagsetmanager.cpp | 2 +-
 libcorpus2/tagsetmanager.h   | 2 +-
 libcorpus2/tagsetparser.h    | 4 ++--
 libcorpus2/token.cpp         | 2 +-
 libpwrutils/exception.cpp    | 6 +++---
 libpwrutils/exception.h      | 6 +++---
 tagset-tool/main.cpp         | 2 +-
 tests/CMakeLists.txt         | 2 +-
 tests/tagset_parse.cpp       | 2 +-
 15 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/libcorpus2/exception.cpp b/libcorpus2/exception.cpp
index 3e0a49a..96e7448 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 e8f221e..ab443b7 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 a951532..a47e3f2 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 70187e3..0a4f6cc 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 3da6172..dd193b3 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 17b2bc8..1a845d8 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 02f6ac3..a9a02fc 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 43ca9e3..fb0f6e9 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 b5febb0..2d2e7ad 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 994de8b..f4317c5 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 35d21b9..f500c11 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 9f0d99c..5ad8a4d 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 97878c9..553bc4d 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 fa3aa8b..d0f1de9 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 4fd78c7..892e072 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;
 		}
-- 
GitLab