Forge
exception.h
Go to the documentation of this file.
1/*******************************************************
2 * Copyright (c) 2015-2019, 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#include <fg/defines.h>
13
14#ifdef __cplusplus
15#include <iostream>
16#include <stdexcept>
17
18namespace forge
19{
20
21class FGAPI Error : public std::exception
22{
23private:
24
25 char mMessage[1024];
26
27 ErrorCode mErrCode;
28
29public:
30
31 ErrorCode err() const { return mErrCode; }
32
34
35 Error(const char * const pMessage);
36
37 Error(const char * const pFileName, int pLine, ErrorCode pErrCode);
38
39 Error(const char * const pMessage, const char * const pFileName, int pLine, ErrorCode pErrCode);
40
41 Error(const char * const pMessage, const char * const pFuncName,
42 const char * const pFileName, int pLine, ErrorCode pErrCode);
43
44 virtual ~Error() throw();
45
46 virtual const char * what() const throw() { return mMessage; }
47
48 friend inline std::ostream& operator<<(std::ostream &s, const Error &e)
49 { return s << e.what(); }
50};
51
52} // namespace forge
53
54#endif
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60FGAPI void fg_get_last_error(char **msg, int *len);
61FGAPI const char * fg_err_to_string(const fg_err err);
62
63#ifdef __cplusplus
64}
65#endif
Definition: exception.h:22
Error(const char *const pMessage)
friend std::ostream & operator<<(std::ostream &s, const Error &e)
Definition: exception.h:48
Error(const char *const pMessage, const char *const pFuncName, const char *const pFileName, int pLine, ErrorCode pErrCode)
ErrorCode err() const
Definition: exception.h:31
virtual ~Error()
Error(const char *const pMessage, const char *const pFileName, int pLine, ErrorCode pErrCode)
virtual const char * what() const
Definition: exception.h:46
Error(const char *const pFileName, int pLine, ErrorCode pErrCode)
#define FGAPI
Definition: defines.h:28
fg_err
Definition: defines.h:49
FGAPI const char * fg_err_to_string(const fg_err err)
FGAPI void fg_get_last_error(char **msg, int *len)
Definition: chart.h:305