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  Error(const Error& error);
45 
46  virtual ~Error() throw();
47 
48  virtual const char * what() const throw() { return mMessage; }
49 
50  friend inline std::ostream& operator<<(std::ostream &s, const Error &e)
51  { return s << e.what(); }
52 };
53 
54 } // namespace forge
55 
56 #endif
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 FGAPI void fg_get_last_error(char **msg, int *len);
63 FGAPI const char * fg_err_to_string(const fg_err err);
64 
65 #ifdef __cplusplus
66 }
67 #endif
forge::Error::what
virtual const char * what() const
Definition: exception.h:62
fg_err
fg_err
Definition: defines.h:49
forge::Error
Definition: exception.h:29
fg_get_last_error
FGAPI void fg_get_last_error(char **msg, int *len)
forge
Definition: chart.h:305
fg_err_to_string
FGAPI const char * fg_err_to_string(const fg_err err)
forge::ErrorCode
fg_err ErrorCode
Definition: defines.h:180
defines.h
FGAPI
#define FGAPI
Definition: defines.h:28