exception.h (2020-07-07 17:43:34 +0530, (build 218dd2c99))
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * https://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #ifdef __cplusplus
13 
14 #include <ostream>
15 #include <af/defines.h>
16 
17 namespace af {
18 
21 class AFAPI exception : public std::exception
22 {
23 private:
24  char m_msg[1024];
25  af_err m_err;
26 public:
27  af_err err() { return m_err; }
30  exception(const char *msg);
31 
34  exception(const char *file, unsigned line, af_err err);
35 
38  exception(const char *msg, const char *file, unsigned line, af_err err);
39 #if AF_API_VERSION >= 33
40  exception(const char *msg, const char *func, const char *file, unsigned line, af_err err);
43 #endif
44  virtual ~exception() throw() {}
46  virtual const char *what() const throw() { return m_msg; }
47 
49  friend inline std::ostream& operator<<(std::ostream &s, const exception &e)
50  { return s << e.what(); }
51 };
52 
53 } // namespace af
54 
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
65 AFAPI void af_get_last_error(char **msg, dim_t *len);
66 
70 AFAPI const char *af_err_to_string(const af_err err);
71 
72 #ifdef __cplusplus
73 }
74 #endif
dim_t
long long dim_t
Definition: defines.h:56
af_err_to_string
AFAPI const char * af_err_to_string(const af_err err)
Converts the af_err error code to its string representation.
AFAPI
#define AFAPI
Definition: defines.h:38
af
Definition: algorithm.h:15
af::exception
An ArrayFire exception class.
Definition: exception.h:29
af_get_last_error
AFAPI void af_get_last_error(char **msg, dim_t *len)
Returns the last error message that occurred and its error message.
af::operator<<
AFAPI array operator<<(const array &lhs, const array &rhs)
Performs an left shift operation on two arrays or an array and a value.
af_err
af_err
Definition: defines.h:71
defines.h