#include <stdexcept>
#include "location.hxx"
#include "localization.hxx"
+//#include "configvariable.hxx"
extern "C"
{
namespace ast
{
+
+enum ExceptionType
+{
+ TYPE_ERROR,
+ TYPE_EXCEPTION
+};
+
class ScilabException : public std::exception
{
public :
- ScilabException()
- {
- createScilabException();
- }
+ ScilabException() {}
- ScilabException(std::wstring _wstErrorMesssage)
+ ScilabException(const std::wstring& _wstErrorMesssage)
{
- setLastError(999, _wstErrorMesssage.c_str(), 0, NULL);
- createScilabException(_wstErrorMesssage);
+ m_type = TYPE_EXCEPTION;
+ createScilabException(_wstErrorMesssage, 999, Location());
}
- ScilabException(std::string _stErrorMesssage)
+ ScilabException(const std::string& _stErrorMesssage)
{
+ m_type = TYPE_EXCEPTION;
wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
- setLastError(999, pwst, 0, NULL);
- createScilabException(pwst);
+ createScilabException(pwst, 999, Location());
FREE(pwst);
}
- ScilabException(const Location& _ErrorLocation)
- {
- createScilabException(L"", 0, _ErrorLocation);
- }
- ScilabException(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
+ ScilabException(const std::wstring& _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
{
- setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), _ErrorLocation.first_line, NULL);
+ m_type = TYPE_EXCEPTION;
createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
}
virtual ~ScilabException() throw() {};
- void SetErrorMessage(std::wstring _wstErrorMesssage)
+ void SetErrorMessage(const std::wstring& _wstErrorMesssage)
{
m_wstErrorMessage = _wstErrorMesssage;
}
{
return m_ErrorLocation;
}
+
+ void SetErrorType(ExceptionType _type)
+ {
+ m_type = _type;
+ }
+
+ ExceptionType GetErrorType(void)
+ {
+ return m_type;
+ }
+
protected :
std::wstring m_wstErrorMessage;
-
int m_iErrorNumber;
Location m_ErrorLocation;
+ ExceptionType m_type;
protected :
- void createScilabException(std::wstring _wstErrorMessage = L"", int _iErrorNumber = 0, const Location& _ErrorLocation = *new Location())
+ void createScilabException(const std::wstring& _wstErrorMessage, int _iErrorNumber, const Location& _ErrorLocation)
{
m_wstErrorMessage = _wstErrorMessage;
m_iErrorNumber = _iErrorNumber;
}
};
-class ScilabError : public ScilabException
-{
-public :
- ScilabError() : ScilabException() {}
- ScilabError(std::wstring _wstErrorMesssage) : ScilabException(_wstErrorMesssage) {}
- ScilabError(std::string _stErrorMesssage) : ScilabException(_stErrorMesssage) {}
- ScilabError(const Location& _ErrorLocation) : ScilabException(_ErrorLocation) {}
- ScilabError(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation) : ScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation) {}
-};
-
-class InternalAbort : public ScilabException
-{
-public :
- InternalAbort() {}
-};
-
-class ScilabMessage : public ScilabException
+class InternalError : public ScilabException
{
public :
- ScilabMessage() : ScilabException() {}
- ScilabMessage(std::wstring _wstErrorMesssage)
+ InternalError(std::wstring _wstErrorMesssage) : ScilabException(_wstErrorMesssage)
{
- createScilabException(_wstErrorMesssage);
+ m_type = TYPE_ERROR;
+ setLastError(999, _wstErrorMesssage.c_str(), 0, NULL);
}
- ScilabMessage(std::string _stErrorMesssage)
+ InternalError(std::string _stErrorMesssage) : ScilabException(_stErrorMesssage)
{
-
- wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
- //setLastError(999, pwst, 0, NULL);
- createScilabException(pwst);
- FREE(pwst);
+ m_type = TYPE_ERROR;
+ setLastError(999, m_wstErrorMessage.c_str(), 0, NULL);
}
- ScilabMessage(const Location& _ErrorLocation) : ScilabException(_ErrorLocation) {}
- ScilabMessage(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
+ InternalError(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation) : ScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation)
{
- //setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), 0, NULL);
- createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
+ m_type = TYPE_ERROR;
+ setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), _ErrorLocation.first_line, NULL);
}
};
+
+class InternalAbort : public ScilabException
+{
+public :
+ InternalAbort() {}
+};
}
#endif // !AST_SCILABEXCEPTION_HXX