source: soft/giet_vm/memo/include/exception.h @ 340

Last change on this file since 340 was 173, checked in by karaoui, 12 years ago

Adding BLOB type for vobj.
Don't forget to set as BLOB type the mapping_info vobj in the xml.

File size: 1.7 KB
Line 
1/* -*- c++ -*-
2 *
3 * Copyright (c) UPMC, Lip6, Asim
4 *      copy of the soclib exception file, original writer:
5 *          Nicolas Pouillon <nipo@ssji.net>, 2007
6 *      modified by:
7 *         Mohamed Lamine Karaoui <Mohamed.Karaoui@lip6.fr>, 2012
8 *
9 */
10
11#ifndef _EXCEPTION_H_
12#define _EXCEPTION_H_
13
14#include <exception>
15#include <string>
16#include <iostream>
17
18namespace exception {
19
20class Exception
21    : public std::exception
22{
23    std::string m_type;
24    std::string m_message;
25
26public:
27    Exception( const std::string &type,
28               const std::string &message )
29            : m_type(type), m_message(message)
30    {}
31
32    virtual ~Exception() throw()
33    {
34    }
35
36    virtual const char * what() const throw()
37    {
38        return m_message.c_str();
39    }
40
41    void print( std::ostream &o ) const
42    {
43        o << "<soclib::exception::" << m_type << ": " << m_message << ">";
44    }
45
46    friend std::ostream &operator << (std::ostream &o, const Exception &e)
47    {
48        e.print(o);
49        return o;
50    }
51};
52
53class ValueError
54    : public Exception
55{
56public:
57    ValueError( const std::string &message )
58            : Exception( "ValueError", message )
59    {}
60};
61
62class Collision
63    : public Exception
64{
65public:
66    Collision( const std::string &message )
67            : Exception( "Collision", message )
68    {}
69};
70
71class RunTimeError
72    : public Exception
73{
74public:
75    RunTimeError( const std::string &message )
76            : Exception( "RunTimeError", message )
77    {}
78};
79
80}
81
82#endif /* SOCLIB_EXCEPTION_H_ */
83
84// Local Variables:
85// tab-width: 4
86// c-basic-offset: 4
87// c-file-offsets:((innamespace . 0)(inline-open . 0))
88// indent-tabs-mode: nil
89// End:
90
91// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
92
Note: See TracBrowser for help on using the repository browser.