MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / af_get_last_error

Function af_get_last_error

src/api/unified/error.cpp:17–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include "symbol_manager.hpp"
16
17void af_get_last_error(char **str, dim_t *len) {
18 // Set error message from unified backend
19 std::string &global_error_string = get_global_error_string();
20 dim_t slen =
21 std::min(MAX_ERR_SIZE, static_cast<int>(global_error_string.size()));
22
23 // If this is true, the error is coming from the unified backend.
24 if (slen != 0) {
25 if (len && slen == 0) {
26 *len = 0;
27 *str = NULL;
28 return;
29 }
30
31 void *in = nullptr;
32 af_alloc_host(&in, sizeof(char) * (slen + 1));
33 memcpy(str, &in, sizeof(void *));
34 global_error_string.copy(*str, slen);
35
36 (*str)[slen] = '\0';
37 global_error_string = std::string("");
38
39 if (len) { *len = slen; }
40 } else {
41 // If false, the error is coming from active backend.
42 typedef void (*af_func)(char **, dim_t *);
43 void *vfn = LOAD_SYMBOL();
44 af_func func = nullptr;
45 memcpy(&func, &vfn, sizeof(void *));
46 func(str, len);
47 }
48}
49
50af_err af_set_enable_stacktrace(int is_enabled) {
51 CALL(af_set_enable_stacktrace, is_enabled);

Callers

nothing calls this directly

Calls 3

af_alloc_hostFunction · 0.70
minFunction · 0.50
copyMethod · 0.45

Tested by

no test coverage detected