presageException.h
Go to the documentation of this file.
/******************************************************
* Presage, an extensible predictive text entry system
* ---------------------------------------------------
*
* Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
**********(*)*/
#ifndef PRESAGE_EXCEPTION
#define PRESAGE_EXCEPTION
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
PRESAGE_OK = 0, /* successful result */
PRESAGE_ERROR, /* generic/unknown presage error */
PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR,
PRESAGE_SMOOTHED_NGRAM_PREDICTOR_LEARN_ERROR,
PRESAGE_CONFIG_VARIABLE_ERROR,
PRESAGE_INVALID_CALLBACK_ERROR,
PRESAGE_INVALID_SUGGESTION_ERROR,
PRESAGE_INIT_PREDICTOR_ERROR,
PRESAGE_SQLITE_OPEN_DATABASE_ERROR,
PRESAGE_SQLITE_EXECUTE_SQL_ERROR
} presage_error_code_t;
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#ifndef _MSC_VER
#include <exception>
#include <string>
class PresageException : public std::exception {
public:
PresageException(presage_error_code_t code, const std::string& msg) throw()
: m_details (msg),
m_code (code)
{
// intentionally empty
}
virtual ~PresageException() throw()
{
// intentionally empty
}
virtual const char* what() const throw()
{
return m_details.c_str();
}
virtual const presage_error_code_t code() const throw()
{
return m_code;
}
private:
std::string m_details;
presage_error_code_t m_code;
};
#endif /* _MSC_VER */
#endif /* __cplusplus */
#endif /* PRESAGE_EXCEPTION */
presage_error_code_t
presage_error_code_t
Definition: presageException.h:32
PRESAGE_CONFIG_VARIABLE_ERROR
Definition: presageException.h:38
PRESAGE_ERROR
Definition: presageException.h:35
PresageException::PresageException
PresageException(presage_error_code_t code, const std::string &msg)
Definition: presageException.h:69
PRESAGE_INVALID_SUGGESTION_ERROR
Definition: presageException.h:40
PresageException::m_code
presage_error_code_t m_code
Definition: presageException.h:93
PRESAGE_SQLITE_OPEN_DATABASE_ERROR
Definition: presageException.h:42
PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR
Definition: presageException.h:36
PRESAGE_OK
Definition: presageException.h:34
PRESAGE_SMOOTHED_NGRAM_PREDICTOR_LEARN_ERROR
Definition: presageException.h:37
PresageException::~PresageException
virtual ~PresageException()
Definition: presageException.h:76
PresageException
Definition: presageException.h:67
PresageException::code
virtual const presage_error_code_t code() const
Definition: presageException.h:86
PRESAGE_SQLITE_EXECUTE_SQL_ERROR
Definition: presageException.h:43
PRESAGE_INVALID_CALLBACK_ERROR
Definition: presageException.h:39
PresageException::what
virtual const char * what() const
Definition: presageException.h:81
PresageException::m_details
std::string m_details
Definition: presageException.h:92
PRESAGE_INIT_PREDICTOR_ERROR
Definition: presageException.h:41