Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / errorhandlers.h
blob6408a3dd705bd35f14687b844754582218658bed
1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * any later version.
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
19 #pragma once
21 #include "functiontypes.h"
22 #include "shapesexceptions.h"
24 namespace Shapes
26 namespace Lang
29 class ErrorHandler : public Lang::Function
31 public:
32 ErrorHandler( );
33 virtual ~ErrorHandler( );
34 virtual bool isTransforming( ) const;
35 virtual void gcMark( Kernel::GCMarkedSet & marked ){ };
38 template< class T >
39 class ExceptionWrapper : public Lang::ErrorHandler
41 protected:
42 const char * title;
43 const char * msg;
44 public:
45 ExceptionWrapper( const char * _title, const char * _msg );
46 virtual ~ExceptionWrapper( );
47 virtual void call( Kernel::EvalState * evalState, Kernel::Arguments & args, const Ast::SourceLocation & callLoc ) const;
54 template< class T >
55 Shapes::Lang::ExceptionWrapper< T >::ExceptionWrapper( const char * _title, const char * _msg )
56 : title( _title ), msg( _msg )
57 { }
59 template< class T >
60 Shapes::Lang::ExceptionWrapper< T >::~ExceptionWrapper( )
61 { }
63 template< class T >
64 void
65 Shapes::Lang::ExceptionWrapper< T >::call( Kernel::EvalState * evalState, Kernel::Arguments & args, const Ast::SourceLocation & callLoc ) const
67 throw T( msg );