NumCpp  2.8.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Error.hpp
Go to the documentation of this file.
1 #pragma once
29 
30 #include <iostream>
31 #include <stdexcept>
32 #include <string>
33 
34 #include "NumCpp/Core/Types.hpp"
35 
36 #define THROW_INVALID_ARGUMENT_ERROR(msg) \
37  nc::error::throwError<std::invalid_argument>(__FILE__, __func__, __LINE__, msg)
38 #define THROW_RUNTIME_ERROR(msg) nc::error::throwError<std::runtime_error>(__FILE__, __func__, __LINE__, msg)
39 
40 namespace nc
41 {
42  namespace error
43  {
44  //============================================================================
52  template<typename ErrorType>
53  void throwError(const std::string& file, const std::string& function, uint32 line, const std::string& msg = "")
54  {
55  std::string errMsg = "File: " + file + "\n\tFunction: " + function + "\n\tLine: " + std::to_string(line) +
56  "\n\tError: " + msg;
57  std::cerr << errMsg;
58  throw ErrorType(errMsg);
59  }
60  } // namespace error
61 } // namespace nc
void throwError(const std::string &file, const std::string &function, uint32 line, const std::string &msg="")
Definition: Error.hpp:53
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40