A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

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 <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; }
28 exception();
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
42 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
af::exception
An ArrayFire exception class.
Definition exception.h:22
af::exception::err
af_err err()
Definition exception.h:27
af::exception::exception
exception()
af::exception::exception
exception(const char *msg, const char *file, unsigned line, af_err err)
Creates a new af::exception with a formatted error message for a given an error code,...
af::exception::~exception
virtual ~exception()
Definition exception.h:44
af::exception::exception
exception(const char *msg, const char *func, const char *file, unsigned line, af_err err)
Creates a new exception given a message, function name, file name, line number and error code.
af::exception::what
virtual const char * what() const
Returns an error message for the exception in a string format.
Definition exception.h:46
af::exception::exception
exception(const char *msg)
Creates a new af::exception given a message. The error code is AF_ERR_UNKNOWN.
af::exception::exception
exception(const char *file, unsigned line, af_err err)
Creates a new exception with a formatted error message for a given file and line number in the source...
af::exception::operator<<
friend std::ostream & operator<<(std::ostream &s, const exception &e)
Writes the exception to a stream.
Definition exception.h:49
defines.h
dim_t
long long dim_t
Definition defines.h:56
af_err
af_err
Definition defines.h:71
AFAPI
#define AFAPI
Definition defines.h:38
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_err_to_string
AFAPI const char * af_err_to_string(const af_err err)
Converts the af_err error code to its string representation.
af
Definition algorithm.h:15