2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Antoine ELIAS
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 * This file is hereby licensed under the terms of the GNU GPL v2.0,
8 * pursuant to article 5.3.4 of the CeCILL v.2.1.
9 * This file was originally licensed under the terms of the CeCILL v2.1,
10 * and continues to be available under such terms.
11 * For more information, see the COPYING file which you should have received
12 * along with this program.
16 #ifndef AST_SCILABEXCEPTION_HXX
17 #define AST_SCILABEXCEPTION_HXX
21 #include "location.hxx"
22 #include "localization.hxx"
23 //#include "configvariable.hxx"
27 #include "lasterror.h"
28 #include "sci_malloc.h"
29 #include "localization.h"
32 //disable warnings about exports STL items
34 #pragma warning (disable : 4251)
46 class ScilabException : public std::exception
49 ScilabException() : m_wstErrorMessage(), m_iErrorNumber(0), m_ErrorLocation(), m_type(TYPE_ERROR) {}
51 ScilabException(const std::wstring& _wstErrorMesssage)
53 m_type = TYPE_EXCEPTION;
54 createScilabException(_wstErrorMesssage, 999, Location());
57 ScilabException(const std::string& _stErrorMesssage)
59 m_type = TYPE_EXCEPTION;
60 wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
61 createScilabException(pwst, 999, Location());
65 ScilabException(const std::wstring& _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
67 m_type = TYPE_EXCEPTION;
68 createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
71 virtual ~ScilabException() throw() {};
73 void SetErrorMessage(const std::wstring& _wstErrorMesssage)
75 m_wstErrorMessage = _wstErrorMesssage;
78 std::wstring GetErrorMessage(void) const
80 return m_wstErrorMessage;
83 void SetErrorNumber(int _iErrorNumber)
85 m_iErrorNumber = _iErrorNumber;
88 int GetErrorNumber(void) const
90 return m_iErrorNumber;
93 void SetErrorLocation(const Location& _ErrorLocation)
95 m_ErrorLocation = _ErrorLocation;
98 const Location& GetErrorLocation(void) const
100 return m_ErrorLocation;
103 void SetErrorType(ExceptionType _type)
108 ExceptionType GetErrorType(void)
114 std::wstring m_wstErrorMessage;
116 Location m_ErrorLocation;
117 ExceptionType m_type;
120 void createScilabException(const std::wstring& _wstErrorMessage, int _iErrorNumber, const Location& _ErrorLocation)
122 m_wstErrorMessage = _wstErrorMessage;
123 m_iErrorNumber = _iErrorNumber;
124 m_ErrorLocation = _ErrorLocation;
128 class InternalError : public ScilabException
131 InternalError(const std::wstring& _wstErrorMesssage) : ScilabException(_wstErrorMesssage)
134 setLastError(999, _wstErrorMesssage.c_str(), 0, NULL);
137 InternalError(std::string _stErrorMesssage) : ScilabException(_stErrorMesssage)
140 setLastError(999, m_wstErrorMessage.c_str(), 0, NULL);
143 InternalError(const std::wstring& _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation) : ScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation)
146 setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), _ErrorLocation.first_line, NULL);
151 class InternalAbort : public ScilabException
157 class RecursionException : public ScilabException
160 RecursionException() {}
163 #endif // !AST_SCILABEXCEPTION_HXX