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 
18 namespace forge
19 {
20 
21 class FGAPI Error : public std::exception
22 {
23 private:
24 
25  char mMessage[1024];
26 
27  ErrorCode mErrCode;
28 
29 public:
30 
31  ErrorCode err() const { return mErrCode; }
32 
33  Error();
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
57 extern "C" {
58 #endif
59 
60 FGAPI void fg_get_last_error(char **msg, int *len);
61 FGAPI const char * fg_err_to_string(const fg_err err);
62 
63 #ifdef __cplusplus
64 }
65 #endif
Definition: chart.h:304
Definition: exception.h:21
virtual const char * what() const
Definition: exception.h:46
ErrorCode err() const
Definition: exception.h:31
friend std::ostream & operator<<(std::ostream &s, const Error &e)
Definition: exception.h:48
#define FGAPI
Definition: defines.h:28
FGAPI void fg_get_last_error(char **msg, int *len)
fg_err
Definition: defines.h:49
FGAPI const char * fg_err_to_string(const fg_err err)