2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Antoine ELIAS
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 #ifndef AST_SCILABEXCEPTION_HXX
14 #define AST_SCILABEXCEPTION_HXX
18 #include "location.hxx"
19 #include "localization.hxx"
23 #include "lasterror.h"
24 #include "sci_malloc.h"
25 #include "localization.h"
28 //disable warnings about exports STL items
30 #pragma warning (disable : 4251)
35 class ScilabException : public std::exception
40 createScilabException(L"", 0, Location());
43 ScilabException(std::wstring _wstErrorMesssage)
45 setLastError(999, _wstErrorMesssage.c_str(), 0, NULL);
46 createScilabException(_wstErrorMesssage, 0, Location());
49 ScilabException(std::string _stErrorMesssage)
51 wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
52 setLastError(999, pwst, 0, NULL);
53 createScilabException(pwst, 0, Location());
56 ScilabException(const Location& _ErrorLocation)
58 createScilabException(L"", 0, _ErrorLocation);
61 ScilabException(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
63 setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), _ErrorLocation.first_line, NULL);
64 createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
67 virtual ~ScilabException() throw() {};
69 void SetErrorMessage(std::wstring _wstErrorMesssage)
71 m_wstErrorMessage = _wstErrorMesssage;
74 std::wstring GetErrorMessage(void) const
76 return m_wstErrorMessage;
79 void SetErrorNumber(int _iErrorNumber)
81 m_iErrorNumber = _iErrorNumber;
84 int GetErrorNumber(void) const
86 return m_iErrorNumber;
89 void SetErrorLocation(const Location& _ErrorLocation)
91 m_ErrorLocation = _ErrorLocation;
94 const Location& GetErrorLocation(void) const
96 return m_ErrorLocation;
99 std::wstring m_wstErrorMessage;
102 Location m_ErrorLocation;
105 void createScilabException(std::wstring _wstErrorMessage, int _iErrorNumber, const Location& _ErrorLocation)
107 m_wstErrorMessage = _wstErrorMessage;
108 m_iErrorNumber = _iErrorNumber;
109 m_ErrorLocation = _ErrorLocation;
113 class ScilabError : public ScilabException
116 ScilabError() : ScilabException() {}
117 ScilabError(std::wstring _wstErrorMesssage) : ScilabException(_wstErrorMesssage) {}
118 ScilabError(std::string _stErrorMesssage) : ScilabException(_stErrorMesssage) {}
119 ScilabError(const Location& _ErrorLocation) : ScilabException(_ErrorLocation) {}
120 ScilabError(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation) : ScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation) {}
123 class InternalAbort : public ScilabException
129 class ScilabMessage : public ScilabException
132 ScilabMessage() : ScilabException() {}
133 ScilabMessage(std::wstring _wstErrorMesssage)
135 createScilabException(_wstErrorMesssage, 0, Location());
138 ScilabMessage(std::string _stErrorMesssage)
141 wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
142 createScilabException(pwst, 0, Location());
146 ScilabMessage(const Location& _ErrorLocation) : ScilabException(_ErrorLocation) {}
147 ScilabMessage(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
149 createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
153 #endif // !AST_SCILABEXCEPTION_HXX