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"
20 //#include "configvariable.hxx"
24 #include "lasterror.h"
25 #include "sci_malloc.h"
26 #include "localization.h"
29 //disable warnings about exports STL items
31 #pragma warning (disable : 4251)
43 class ScilabException : public std::exception
48 ScilabException(const std::wstring& _wstErrorMesssage)
50 m_type = TYPE_EXCEPTION;
51 createScilabException(_wstErrorMesssage, 999, Location());
54 ScilabException(const std::string& _stErrorMesssage)
56 m_type = TYPE_EXCEPTION;
57 wchar_t* pwst = to_wide_string(_stErrorMesssage.c_str());
58 createScilabException(pwst, 999, Location());
62 ScilabException(const std::wstring& _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation)
64 m_type = TYPE_EXCEPTION;
65 createScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation);
68 virtual ~ScilabException() throw() {};
70 void SetErrorMessage(const std::wstring& _wstErrorMesssage)
72 m_wstErrorMessage = _wstErrorMesssage;
75 std::wstring GetErrorMessage(void) const
77 return m_wstErrorMessage;
80 void SetErrorNumber(int _iErrorNumber)
82 m_iErrorNumber = _iErrorNumber;
85 int GetErrorNumber(void) const
87 return m_iErrorNumber;
90 void SetErrorLocation(const Location& _ErrorLocation)
92 m_ErrorLocation = _ErrorLocation;
95 const Location& GetErrorLocation(void) const
97 return m_ErrorLocation;
100 void SetErrorType(ExceptionType _type)
105 ExceptionType GetErrorType(void)
111 std::wstring m_wstErrorMessage;
113 Location m_ErrorLocation;
114 ExceptionType m_type;
117 void createScilabException(const std::wstring& _wstErrorMessage, int _iErrorNumber, const Location& _ErrorLocation)
119 m_wstErrorMessage = _wstErrorMessage;
120 m_iErrorNumber = _iErrorNumber;
121 m_ErrorLocation = _ErrorLocation;
125 class InternalError : public ScilabException
128 InternalError(std::wstring _wstErrorMesssage) : ScilabException(_wstErrorMesssage)
131 setLastError(999, _wstErrorMesssage.c_str(), 0, NULL);
134 InternalError(std::string _stErrorMesssage) : ScilabException(_stErrorMesssage)
137 setLastError(999, m_wstErrorMessage.c_str(), 0, NULL);
140 InternalError(std::wstring _wstErrorMesssage, int _iErrorNumber, const Location& _ErrorLocation) : ScilabException(_wstErrorMesssage, _iErrorNumber, _ErrorLocation)
143 setLastError(_iErrorNumber, _wstErrorMesssage.c_str(), _ErrorLocation.first_line, NULL);
147 class InternalAbort : public ScilabException
153 #endif // !AST_SCILABEXCEPTION_HXX