NumCpp  2.7.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 "NumCpp/Core/Types.hpp"
31 
32 #include <iostream>
33 #include <stdexcept>
34 #include <string>
35 
36 #define THROW_INVALID_ARGUMENT_ERROR(msg) nc::error::throwError<std::invalid_argument>(__FILE__, __func__, __LINE__, msg)
37 #define THROW_RUNTIME_ERROR(msg) nc::error::throwError<std::runtime_error>(__FILE__, __func__, __LINE__, msg)
38 
39 namespace nc
40 {
41  namespace error
42  {
43  //============================================================================
51  template<typename ErrorType>
52  void throwError(const std::string& file,
53  const std::string& function,
54  uint32 line,
55  const std::string& msg = "")
56  {
57  std::string errMsg = "File: " + file + "\n\tFunction: " + function + "\n\tLine: " + std::to_string(line) + "\n\tError: " + msg;
58  std::cerr << errMsg;
59  throw ErrorType(errMsg);
60  }
61  } // namespace error
62 } // namespace nc
void throwError(const std::string &file, const std::string &function, uint32 line, const std::string &msg="")
Definition: Error.hpp:52
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40