NumCpp
2.1.0
A C++ implementation of the Python Numpy library
Error.hpp
Go to the documentation of this file.
1
#pragma once
30
31
#include "
NumCpp/Core/Types.hpp
"
32
33
#include <iostream>
34
#include <stdexcept>
35
#include <string>
36
37
#define THROW_INVALID_ARGUMENT_ERROR(msg) 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,
54
const
std::string&
function
,
55
uint32
line,
56
const
std::string& msg =
""
)
57
{
58
std::string errMsg =
"File: "
+ file +
"\n\tFunction: "
+
function
+
"\n\tLine: "
+ std::to_string(line) +
"\n\tError: "
+ msg;
59
std::cerr << errMsg;
60
throw
ErrorType(errMsg);
61
}
62
}
// namespace error
63
}
// namespace nc
nc::uint32
std::uint32_t uint32
Definition:
Types.hpp:41
nc
Definition:
Coordinate.hpp:45
nc::error::throwError
void throwError(const std::string &file, const std::string &function, uint32 line, const std::string &msg="")
Definition:
Error.hpp:53
Types.hpp
include
NumCpp
Core
Internal
Error.hpp
Generated by
1.8.17