exception.h
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  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #pragma once
11 
12 #ifdef __cplusplus
13 
14 #include <iostream>
15 #include <af/defines.h>
16 
17 namespace af {
18 
19 class AFAPI exception : public std::exception
20 {
21 private:
22  char m_msg[1024];
23  af_err m_err;
24 public:
25  af_err err() { return m_err; }
26  exception();
27  exception(const char *msg);
28  exception(const char *file, unsigned line, af_err err);
29  exception(const char *msg, const char *file, unsigned line, af_err err);
30 #if AF_API_VERSION >= 33
31  exception(const char *msg, const char *func, const char *file, unsigned line, af_err err);
32 #endif
33  virtual ~exception() throw() {}
34  virtual const char *what() const throw() { return m_msg; }
35  friend inline std::ostream& operator<<(std::ostream &s, const exception &e)
36  { return s << e.what(); }
37 };
38 
39 }
40 
41 #endif
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 AFAPI void af_get_last_error(char **msg, dim_t *len);
48 AFAPI const char *af_err_to_string(const af_err err);
49 
50 #ifdef __cplusplus
51 }
52 #endif
Definition: exception.h:19
Definition: algorithm.h:14
AFAPI void af_get_last_error(char **msg, dim_t *len)
friend std::ostream & operator<<(std::ostream &s, const exception &e)
Definition: exception.h:35
virtual ~exception()
Definition: exception.h:33
af_err err()
Definition: exception.h:25
af_err
Definition: defines.h:63
long long dim_t
Definition: defines.h:50
#define AFAPI
Definition: defines.h:31
virtual const char * what() const
Definition: exception.h:34
AFAPI const char * af_err_to_string(const af_err err)