FiReS  0.2.0
FiReS - Filter, Retrieval and Search
error.h
1 /*
2  * Copyright (c) 2014-2016 VG-Lab/URJC.
3  *
4  * Authors: Pablo Toharia <pablo.toharia@urjc.es>
5  *
6  * This file is part of FiReS <https://github.com/vg-lab/FiReS>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License version 3.0 as published
10  * by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22 #ifndef __FIRES__ERROR__
23 #define __FIRES__ERROR__
24 
25 #include <stdexcept>
26 
27 namespace fires
28 {
29  typedef std::runtime_error exception;
30 }
31 
32 #define FIRES_THROW( msg ) \
33  { \
34  Log::log( msg, LOG_LEVEL_ERROR ); \
35  throw std::runtime_error( msg ); \
36  }
37 
38 #define FIRES_CHECK_THROW( cond, errorMsg ) \
39  { \
40  if ( ! (cond) ) FIRES_THROW( errorMsg ); \
41  }
42 
43 #ifndef NDEBUG
44  #define FIRES_DEBUG_CHECK( cond, errorMsg ) \
45 { \
46  FIRES_CHECK_THROW( cond, errorMsg ) \
47 }
48 #else
49  #define FIRES_DEBUG_CHECK( cond, errorMsg )
50 #endif
51 
52 
53 #endif // __FIRES_ERROR__