nsol  0.4.1
Nsol - Neuroscience Objects Library
error.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2017 VG-Lab/URJC.
3  *
4  * Authors: Pablo Toharia <pablo.toharia@urjc.es>
5  *
6  * This file is part of nsol <https://github.com/vg-lab/nsol>
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  */
30 #ifndef __NSOL_ERROR__
31 #define __NSOL_ERROR__
32 
33 
34 #include "Log.h"
35 #include <stdexcept>
36 
37 
38 #define NSOL_THROW( msg ) \
39  { \
40  nsol::Log::log( std::string( msg ), nsol::LOG_LEVEL_ERROR ); \
41  throw std::runtime_error( msg ); \
42  }
43 
44 #define NSOL_CHECK_THROW( cond, errorMsg ) \
45  { \
46  if ( ! (cond) ) NSOL_THROW( errorMsg ); \
47  }
48 
49 #ifdef DEBUG
50  #define NSOL_DEBUG_CHECK( cond, errorMsg ) \
51 { \
52  NSOL_CHECK_THROW( cond, errorMsg ) \
53 }
54 #else
55  #define NSOL_DEBUG_CHECK( cond, errorMsg )
56 #endif
57 
58 
59 #endif // __NSOL_ERROR__