#ifndef Morpheo_ErrorMorpheo_h
#define Morpheo_ErrorMorpheo_h

/*
 * $Id: ErrorMorpheo.h 88 2008-12-10 18:31:39Z rosiere $
 *
 * [ Description ]
 * 
 */

#include "Common/include/ToString.h"
#include "Common/include/Translation.h"
#include "Common/include/Message.h"

#include <iostream>
#include <exception>

namespace morpheo              {

#define ERRORMORPHEO(funcname,msg) ErrorMorpheo(funcname,msg,__LINE__,__FILE__)

  class ErrorMorpheo : public std::exception 
  {
    // -----[ fields ]----------------------------------------------------
  private : std::string _msg;
    
    // -----[ methods ]---------------------------------------------------
  public  :             ErrorMorpheo  ()                throw() {_msg = toString("%s ",MSG_ERROR); _msg+="Exception detected ...";}
  public  :             ErrorMorpheo  (std::string msg) throw() {_msg = toString("%s ",MSG_ERROR); _msg+=msg;}
  public  :             ErrorMorpheo  (std::string funcname,
				       std::string msg     ,
				       int         line    ,
				       std::string file    ) throw() 
    { 
#ifdef DEBUG
      _msg = toString(_("%s <%s> at line %d, in file %s : %s"),MSG_ERROR,funcname.c_str(),line,file.c_str(),msg.c_str());
#else
      _msg = toString(_("%s %s"),MSG_ERROR,msg.c_str());
#endif
    }
  public  :             ~ErrorMorpheo (void)       throw() {}
  public  : const char* what          ()    const  throw() { return ( _msg.c_str() );}

  };

  class TestMorpheo : public std::exception 
  {
    // -----[ fields ]----------------------------------------------------
  private : std::string _msg;
    
    // -----[ methods ]---------------------------------------------------
  public  :             TestMorpheo   ()                throw() {_msg=_("Test error ...");}
  public  :             TestMorpheo   (std::string msg) throw() {_msg=msg;}
  public  :             ~TestMorpheo  (void)            throw() {}
  public  : const char* what          ()    const       throw() { return ( _msg.c_str() );}
  };

}; // end namespace morpheo              

#endif
