forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.cpp
More file actions
63 lines (56 loc) · 2.62 KB
/
error.cpp
File metadata and controls
63 lines (56 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <af/exception.h>
#include <af/device.h>
#include <err_common.hpp>
#include <string>
#include <algorithm>
void af_get_last_error(char **str, dim_t *len)
{
std::string &global_error_string = get_global_error_string();
dim_t slen = std::min(MAX_ERR_SIZE, (int)global_error_string.size());
if (len && slen == 0) {
*len = 0;
*str = NULL;
return;
}
af_alloc_host((void**)str, sizeof(char) * (slen + 1));
global_error_string.copy(*str, slen);
(*str)[slen] = '\0';
global_error_string = std::string("");
if(len) *len = slen;
}
const char *af_err_to_string(const af_err err)
{
switch (err) {
case AF_SUCCESS: return "Success";
case AF_ERR_NO_MEM: return "Device out of memory";
case AF_ERR_DRIVER: return "Driver not available or incompatible";
case AF_ERR_RUNTIME: return "Runtime error ";
case AF_ERR_INVALID_ARRAY: return "Invalid array";
case AF_ERR_ARG: return "Invalid input argument";
case AF_ERR_SIZE: return "Invalid input size";
case AF_ERR_TYPE: return "Function does not support this data type";
case AF_ERR_DIFF_TYPE: return "Input types are not the same";
case AF_ERR_BATCH: return "Invalid batch configuration";
case AF_ERR_NOT_SUPPORTED: return "Function not supported";
case AF_ERR_NOT_CONFIGURED: return "Function not configured to build";
case AF_ERR_NONFREE: return "Function unavailable. "
"ArrayFire compiled without Non-Free algorithms support";
case AF_ERR_NO_DBL: return "Double precision not supported for this device";
case AF_ERR_NO_GFX: return "Graphics functionality unavailable. "
"ArrayFire compiled without Graphics support";
case AF_ERR_LOAD_LIB: return "Failed to load dynamic library. ";
case AF_ERR_LOAD_SYM: return "Failed to load symbol";
case AF_ERR_ARR_BKND_MISMATCH: return "There was a mismatch between an array and the current backend";
case AF_ERR_INTERNAL: return "Internal error";
case AF_ERR_UNKNOWN:
default: return "Unknown error";
}
}