STIR  6.2.0
error.h
Go to the documentation of this file.
1 //
2 //
3 #ifndef __stir_error_H__
4 #define __stir_error_H__
5 /*
6  Copyright (C) 2000 PARAPET partners
7  Copyright (C) 2000 - 2010-06-25, Hammersmith Imanet Ltd
8  Copyright (C) 2013-01-01 - 2013, Kris Thielemans
9  This file is part of STIR.
10  SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
11 
12  See STIR/LICENSE.txt for details
13 */
22 #include "stir/common.h"
23 #include <iostream>
24 #include <sstream>
25 
26 #include "TextWriter.h"
27 
28 START_NAMESPACE_STIR
29 
31 
49 void error(const char* const s, ...);
50 
52 
72 template <class STRING>
73 inline void
74 error(const STRING& string)
75 {
76  std::stringstream sstr;
77  sstr << "\nERROR: " << string << std::endl;
78  writeText(sstr.str().c_str(), ERROR_CHANNEL);
79  throw std::runtime_error(sstr.str());
80 }
81 
82 END_NAMESPACE_STIR
83 #endif
void error(const STRING &string)
Use this function for writing error messages and throwing an exception.
Definition: error.h:74
basic configuration include file