forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception.cpp
More file actions
59 lines (47 loc) · 1.62 KB
/
exception.cpp
File metadata and controls
59 lines (47 loc) · 1.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
/*******************************************************
* 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 <string.h> // strncpy
#include <stdio.h>
#include <af/exception.h>
#include <algorithm>
#ifdef OS_WIN
#define snprintf _snprintf
#endif
namespace af {
exception::exception(): m_err(AF_ERR_UNKNOWN)
{
strncpy(m_msg, "unknown exception", sizeof(m_msg));
}
exception::exception(const char *msg): m_err(AF_ERR_UNKNOWN)
{
strncpy(m_msg, msg, sizeof(m_msg));
m_msg[sizeof(m_msg)-1] = '\0';
}
exception::exception(const char *file, unsigned line, af_err err): m_err(err)
{
snprintf(m_msg, sizeof(m_msg) - 1,
"ArrayFire Exception (%s:%d):\nIn %s:%u",
af_err_to_string(err), (int)err, file, line);
m_msg[sizeof(m_msg)-1] = '\0';
}
exception::exception(const char *msg, const char *file, unsigned line, af_err err): m_err(err)
{
snprintf(m_msg, sizeof(m_msg) - 1,
"ArrayFire Exception (%s:%d):\n%s\nIn %s:%u",
af_err_to_string(err), (int)(err), msg, file, line);
m_msg[sizeof(m_msg)-1] = '\0';
}
exception::exception(const char *msg, const char *func, const char *file, unsigned line, af_err err): m_err(err)
{
snprintf(m_msg, sizeof(m_msg) - 1,
"ArrayFire Exception (%s:%d):\n%s\nIn function %s\nIn file %s:%u",
af_err_to_string(err), (int)(err), msg, func, file, line);
m_msg[sizeof(m_msg)-1] = '\0';
}
}