ErrorHandling#
-
class numpy::ErrorHandling#
numpy C++ class.
Example#
#include <numpy/np_ndarray.h>
using namespace numpy;
// Use ErrorHandling
ErrorHandling obj;
// ... operations ...
Indexing / Selection#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
size_t |
NP_ERROR_HANDLING.H:129 |
|
|
ErrorState |
NP_ERROR_HANDLING.H:86 |
Other Methods#
Signature |
Return Type |
Location |
Example |
|---|---|---|---|
|
void |
NP_ERROR_HANDLING.H:109 |
|
|
void |
NP_ERROR_HANDLING.H:141 |
|
|
void |
NP_ERROR_HANDLING.H:135 |
|
|
void |
NP_ERROR_HANDLING.H:123 |
|
|
void |
NP_ERROR_HANDLING.H:95 |
|
|
void |
NP_ERROR_HANDLING.H:101 |
Code Examples#
The following examples are extracted from the test suite.
handle_error (np_test_2_all.cpp:19467)
19457 callback_message = msg;
19458 };
19459
19460 // Set callback
19461 auto old_callback = numpy::config::seterrcall(callback);
19462
19463 // Set mode to "call"
19464 auto old_state = numpy::config::seterr("call", "", "", "");
19465
19466 // Trigger error
19467 numpy::config::ErrorHandling::handle_error("divide", "Test error message");
19468
19469 if (!callback_called) {
19470 std::cout << " [FAIL] : Callback was not called";
19471 throw std::runtime_error("np_test_error_callback failed: not called");
19472 }
19473
19474 if (callback_message != "Test error message") {
19475 std::cout << " [FAIL] : Callback message incorrect";
19476 throw std::runtime_error("np_test_error_callback failed: message");
19477 }