File: exception.h

package info (click to toggle)
forge 1.0.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,312 kB
  • sloc: cpp: 12,447; ansic: 319; xml: 182; makefile: 19
file content (65 lines) | stat: -rw-r--r-- 1,415 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************
 * Copyright (c) 2015-2019, ArrayFire
 * All rights reserved.
 *
 * This file is distributed under 3-clause BSD license.
 * The complete license agreement can be obtained at:
 * http://arrayfire.com/licenses/BSD-3-Clause
 ********************************************************/

#pragma once

#include <fg/defines.h>

#ifdef __cplusplus
#include <iostream>
#include <stdexcept>

namespace forge
{

class FGAPI Error : public std::exception
{
private:

    char        mMessage[1024];

    ErrorCode   mErrCode;

public:

    ErrorCode err() const { return mErrCode; }

    Error();

    Error(const char * const pMessage);

    Error(const char * const pFileName, int pLine, ErrorCode pErrCode);

    Error(const char * const pMessage, const char * const pFileName, int pLine, ErrorCode pErrCode);

    Error(const char * const pMessage, const char * const pFuncName,
          const char * const pFileName, int pLine, ErrorCode pErrCode);

    virtual ~Error() throw();

    virtual const char * what() const throw() { return mMessage; }

    friend inline std::ostream& operator<<(std::ostream &s, const Error &e)
    { return s << e.what(); }
};

} // namespace forge

#endif

#ifdef __cplusplus
extern "C" {
#endif

FGAPI void fg_get_last_error(char **msg, int *len);
FGAPI const char * fg_err_to_string(const fg_err err);

#ifdef __cplusplus
}
#endif