Skip to content
Snippets Groups Projects
Commit 83bbfa4d authored by ilor's avatar ilor
Browse files

add a WcclError exception class

parent 3a20e3be
No related merge requests found
...@@ -12,6 +12,7 @@ set(LIBS ${LIBS} ${Boost_LIBRARIES}) ...@@ -12,6 +12,7 @@ set(LIBS ${LIBS} ${Boost_LIBRARIES})
SET(libwccl_STAT_SRC SET(libwccl_STAT_SRC
bool.cpp bool.cpp
exception.cpp
main.cpp main.cpp
position.cpp position.cpp
sentencecontext.cpp sentencecontext.cpp
......
#include <libwccl/exception.h>
#include <sstream>
namespace Wccl {
WcclError::WcclError(const std::string &what)
: PwrNlp::PwrNlpError(what)
{
}
WcclError::~WcclError() throw()
{
}
std::string WcclError::scope() const
{
return "Wccl";
}
FileNotFound::FileNotFound(const std::string& filename,
const std::string& paths, const std::string& where)
: WcclError("File not found: " + filename), filename(filename),
paths(paths), where(where)
{
}
FileNotFound::~FileNotFound() throw()
{
}
std::string FileNotFound::info() const
{
std::ostringstream ss;
if (where.empty()) {
ss << "File ";
} else {
ss << where << " file ";
}
ss << "'" << filename << "' not found in search path " << paths;
return ss.str();
}
} /* end ns Wccl */
#ifndef LIBWCCL_EXCEPTION_H
#define LIBWCCL_EXCEPTION_H
#include <libpwrutils/exception.h>
namespace Wccl {
/**
* Base class for all Wccl errorss. Derives from
* @c std::runtime_error. Call member function @c what to get a
* human-readable message associated with the error.
*/
class WcclError : public PwrNlp::PwrNlpError
{
public:
/**
* Instantiate a WcclError instance with the given message.
* @param what The message to associate with this error.
*/
WcclError(const std::string &what);
~WcclError() throw();
/// PwrNlpError override
std::string scope() const;
};
class FileNotFound : public WcclError
{
public:
FileNotFound(const std::string& filename, const std::string& paths,
const std::string& where);
~FileNotFound() throw();
std::string info() const;
std::string filename, paths, where;
};
} /* end ns Wccl */
#endif // LIBWCCL_EXCEPTION_H
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment