2
This file is part of the Grantlee template system.
4
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either version
9
2 of the Licence, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
#ifndef GRANTLEE_EXCEPTION_H
22
#define GRANTLEE_EXCEPTION_H
24
#include <QtCore/QString>
33
Types of errors that can occur while using %Grantlee
40
UnclosedBlockTagError,
43
// VariableSyntaxError,
46
ObjectReturnTypeInvalid,
51
/// @headerfile exception.h grantlee/exception.h
54
@brief An exception for use when implementing template tags.
56
The exception class can be used when implementing AbstractNodeFactory::getNode. An exception can be thrown to indicate that
57
the syntax of a particular tag is invalid.
59
For example, the following template markup should throw an error because the include tag should have exactly one argument:
66
The corresponding implementation of IncludeNodeFactory::getNode is
69
QStringList tagContents = smartSplit( tagContent );
71
if ( tagContents.size() != 2 )
72
throw Grantlee::Exception( TagSyntaxError, "Error: Include tag takes exactly one argument" );
74
// The item at index 0 in the list is the tag name, "include"
75
QString includeName = tagContents.at( 1 );
79
class GRANTLEE_CORE_EXPORT Exception
83
Creates an exception for the error @p errorCode and the verbose message @p what
85
Exception( Error errorCode, const QString &what )
86
: m_errorCode( errorCode ), m_what( what ) {}
88
virtual ~Exception() throw() {}
94
Returns the verbose message for the exception.
96
const QString what() const throw() {
103
Returns the error code for the exception.
105
Error errorCode() const {