source: trunk/IPs/systemC/processor/Morpheo/Common/include/ErrorMorpheo.h @ 103

Last change on this file since 103 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 2.0 KB
RevLine 
[88]1#ifndef Morpheo_ErrorMorpheo_h
2#define Morpheo_ErrorMorpheo_h
[2]3
4/*
5 * $Id: ErrorMorpheo.h 88 2008-12-10 18:31:39Z rosiere $
6 *
[71]7 * [ Description ]
[2]8 *
9 */
10
[88]11#include "Common/include/ToString.h"
12#include "Common/include/Translation.h"
13#include "Common/include/Message.h"
14
[2]15#include <iostream>
16#include <exception>
17
18namespace morpheo              {
19
[71]20#define ERRORMORPHEO(funcname,msg) ErrorMorpheo(funcname,msg,__LINE__,__FILE__)
21
22  class ErrorMorpheo : public std::exception
[2]23  {
24    // -----[ fields ]----------------------------------------------------
[71]25  private : std::string _msg;
[2]26   
27    // -----[ methods ]---------------------------------------------------
[88]28  public  :             ErrorMorpheo  ()                throw() {_msg = toString("%s ",MSG_ERROR); _msg+="Exception detected ...";}
29  public  :             ErrorMorpheo  (std::string msg) throw() {_msg = toString("%s ",MSG_ERROR); _msg+=msg;}
[71]30  public  :             ErrorMorpheo  (std::string funcname,
31                                       std::string msg     ,
32                                       int         line    ,
33                                       std::string file    ) throw() 
34    { 
[88]35#ifdef DEBUG
36      _msg = toString(_("%s <%s> at line %d, in file %s : %s"),MSG_ERROR,funcname.c_str(),line,file.c_str(),msg.c_str());
37#else
38      _msg = toString(_("%s %s"),MSG_ERROR,msg.c_str());
39#endif
[71]40    }
[2]41  public  :             ~ErrorMorpheo (void)       throw() {}
42  public  : const char* what          ()    const  throw() { return ( _msg.c_str() );}
43
44  };
45
[71]46  class TestMorpheo : public std::exception
[3]47  {
48    // -----[ fields ]----------------------------------------------------
[71]49  private : std::string _msg;
[3]50   
51    // -----[ methods ]---------------------------------------------------
[88]52  public  :             TestMorpheo   ()                throw() {_msg=_("Test error ...");}
[71]53  public  :             TestMorpheo   (std::string msg) throw() {_msg=msg;}
54  public  :             ~TestMorpheo  (void)            throw() {}
55  public  : const char* what          ()    const       throw() { return ( _msg.c_str() );}
[3]56  };
57
[2]58}; // end namespace morpheo             
59
60#endif
Note: See TracBrowser for help on using the repository browser.