Project

Profile

Help

Download (2.02 KB) Statistics
| Branch: | Revision:

he / src / main / c / Saxon.C.API / SaxonApiException.cpp @ 7728ae0b

1 72bf04c6 Norman Walsh
// SaxonApiException.cpp : Defines the exported functions for the DLL application.
2
//
3
4
#include "SaxonApiException.h"
5
6
7 55b80284 O'Neil Delpratt
#ifdef MEM_DEBUG
8
#define new new(__FILE__, __LINE__)
9
#endif
10 72bf04c6 Norman Walsh
11
  const char * SaxonApiException::what () {
12
        return message.c_str();
13
  }
14
15
  SaxonApiException::SaxonApiException(){
16
            message = "";
17
            lineNumber = -1;
18
            errorCode = "";
19
            systemId = "";
20
    }
21
22
23
        SaxonApiException::SaxonApiException(const SaxonApiException &ex){
24
                message = ex.message;
25
                lineNumber = ex.lineNumber;
26
                errorCode = ex.errorCode;
27
                systemId = ex.systemId;
28
        }
29
30
31 501beb26 O'Neil Delpratt
SaxonApiException::SaxonApiException(const char * m){
32
    if(m != nullptr) {
33
        message = std::string(m);
34
    } else {
35
        message = "";
36
    }
37
38
    lineNumber = -1;
39
    errorCode = "";
40
    systemId = "";
41
42
}
43
44
45 72bf04c6 Norman Walsh
        SaxonApiException::SaxonApiException(const char * m, const char * ec, const char * sysId, int linenumber){
46 ead48a5d O'Neil Delpratt
                if(m != nullptr) {
47 72bf04c6 Norman Walsh
                    message = std::string(m);
48
                } else {
49
                    message = "";
50
                }
51
52
        lineNumber = linenumber;
53
54 ead48a5d O'Neil Delpratt
        if (ec != nullptr) {
55 72bf04c6 Norman Walsh
            errorCode = std::string(ec);
56
        } else {
57
            errorCode = "";
58
        }
59
60 ead48a5d O'Neil Delpratt
        if(sysId != nullptr) {
61 72bf04c6 Norman Walsh
            systemId = sysId;
62
        } else {
63
            systemId = "";
64
        }
65
        }
66
67
68
69
70
    /**
71
     * A destructor.
72
     */
73 ead48a5d O'Neil Delpratt
        SaxonApiException::~SaxonApiException() noexcept {
74 01d6fdb6 O'Neil Delpratt
            std::cerr<<"SaxonApiException destructor called"<<std::endl;
75 72bf04c6 Norman Walsh
        message.clear();
76
        errorCode.clear();
77
        systemId.clear();
78
        }
79
80
    /**
81
     * Get the error code associated with the ith exception in the vector, if there is one
82
     * @param i - ith exception in the vector
83 ead48a5d O'Neil Delpratt
     * @return the associated error code, or nullptr if no error code is available
84 72bf04c6 Norman Walsh
     */
85
        const char * SaxonApiException::getErrorCode(){
86
                return errorCode.c_str();
87
        }
88
89
90
        int SaxonApiException::getLineNumber(){
91
        return lineNumber;
92
        }
93
94
95
    const char * SaxonApiException::getSystemId() {
96
        return systemId.c_str();
97
    }
98
99
        const char * SaxonApiException::getMessage(){
100
            return message.c_str();
101
102
        }