//
// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// SemanticError.h -- 
//
// Author           : Richard C. Bilson
// Created On       : Mon May 18 07:44:20 2015
// Last Modified By : Peter A. Buhr
// Last Modified On : Mon Jun  8 14:38:53 2015
// Update Count     : 4
//

#ifndef SEMANTICERROR_H
#define SEMANTICERROR_H

#include <exception>
#include <string>
#include <sstream>
#include <list>
#include <iostream>

class SemanticError : public std::exception {
  public:
	SemanticError();
	SemanticError( std::string error );
	template< typename T > SemanticError( const std::string &error, const T *obj );
	~SemanticError() throw() {}

	void append( SemanticError &other );
	bool isEmpty() const;
	void print( std::ostream &os );

	// constructs an exception using the given message and the printed
	// representation of the obj (T must have a print method)
  private:
	std::list< std::string > errors;
};

template< typename T >
SemanticError::SemanticError( const std::string &error, const T *obj ) {
	std::ostringstream os;
	os << "Error: " << error;
	obj->print( os );
	errors.push_back( os.str() );
}

#endif // SEMANTICERROR_H

// Local Variables: //
// tab-width: 4 //
// mode: c++ //
// compile-command: "make install" //
// End: //
