Update procedures
[shapes.git] / source / errorhandlers.h
blob526a0fc33a31ab3464c7f4aeac90c919276de8c1
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, 2014 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 Ast::PlacedIdentifier title_;
43 const char * msg_;
44 public:
45 ExceptionWrapper( const Ast::PlacedIdentifier & 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 Ast::PlacedIdentifier & 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_ );