Grantlee  0.4.0
templates/lib/exception.h
00001 /*
00002   This file is part of the Grantlee template system.
00003 
00004   Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either version
00009   2.1 of the Licence, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 */
00020 
00021 #ifndef GRANTLEE_EXCEPTION_H
00022 #define GRANTLEE_EXCEPTION_H
00023 
00024 #include "grantlee_core_export.h"
00025 
00026 #include <QtCore/QString>
00027 
00028 #include <exception>
00029 
00030 namespace Grantlee
00031 {
00032 
00033 
00037 enum Error {
00038   NoError,
00039   EmptyVariableError,
00040   EmptyBlockTagError,
00041   InvalidBlockTagError,
00042   UnclosedBlockTagError,
00043   UnknownFilterError,
00044   TagSyntaxError,
00045 //   VariableSyntaxError,
00046 
00047   VariableNotInContext,
00048   ObjectReturnTypeInvalid,
00049   CompileFunctionError
00050 };
00051 
00052 
00054 
00081 class GRANTLEE_CORE_EXPORT Exception
00082 {
00083 public:
00087   Exception( Error errorCode, const QString &what )
00088     : m_errorCode( errorCode ), m_what( what ) {}
00089 
00090   virtual ~Exception() throw() {}
00091 
00092 #ifndef Q_QDOC
00093 
00098   const QString what() const throw() {
00099     return m_what;
00100   }
00101 
00107   Error errorCode() const {
00108     return m_errorCode;
00109   }
00110 #endif
00111 
00112 private:
00113   Error m_errorCode;
00114   QString m_what;
00115 };
00116 
00117 }
00118 
00119 #endif
00120