Grantlee: Grantlee::Exception Class Reference

Grantlee 5.3.0

Public Member Functions | List of all members
Grantlee::Exception Class Reference

An exception for use when implementing template tags. More...

`#include <grantlee/exception.h>`

## Public Member Functions
| Exception (Error errorCode, const QString &what)

## Detailed Description

The Exception class can be used when implementing AbstractNodeFactory::getNode. An exception can be thrown to indicate that the syntax of a particular tag is invalid.

For example, the following template markup should throw an error because the include tag should have exactly one argument:

<div>
{% include %}
</div>

The corresponding implementation of IncludeNodeFactory::getNode is

QStringList tagContents = smartSplit( tagContent );
if ( tagContents.size() != 2 )
throw Grantlee::Exception( TagSyntaxError,
"Error: Include tag takes exactly one argument" );
// The item at index 0 in the list is the tag name, "include"
QString includeName = tagContents.at( 1 );
Grantlee::Exception
An exception for use when implementing template tags.
Definition exception.h:85

Author
  Stephen Kelly steve.nosp@m.ire@.nosp@m.gmail.nosp@m..com

Definition at line 84 of file exception.h.

## Constructor & Destructor Documentation

## ◆ Exception()

Grantlee::Exception::Exception | ( | Error | errorCode,
|  | const QString & | what )
| inline

Creates an exception for the error `errorCode` and the verbose message `what`

Definition at line 91 of file exception.h.

## ◆ ~Exception()

virtual Grantlee::Exception::~Exception | ( |  | ) |
throw | ( | ) |  |  |
| inlinevirtual

Definition at line 96 of file exception.h.