summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/ErrorHandler.h
blob: 5f1696700292fe24d944cbf6282e335237f10725 (plain)
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
#ifndef ERROR_HANDLER_H
#define ERROR_HANDLER_H

#include <sax/ErrorHandler.hpp>
#include <sax/SAXParseException.hpp>

#include <Freeze/Print.h>

class DOMTreeErrorReporter : public ErrorHandler
{
public:
    DOMTreeErrorReporter() :
       _sawErrors(false)
    {
    }

    void
    warning(const SAXParseException& toCatch)
    {
	::std::cerr << "Warning at file \"" << DOMString(toCatch.getSystemId())
		    << "\", line " << toCatch.getLineNumber()
		    << ", column " << toCatch.getColumnNumber()
		    << "\n   Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
    }
    
    void
    error(const SAXParseException& toCatch)
    {
	_sawErrors = true;
	::std::cerr << "Error at file \"" << DOMString(toCatch.getSystemId())
		    << "\", line " << toCatch.getLineNumber()
		    << ", column " << toCatch.getColumnNumber()
		    << "\n   Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
	
    }

    void
    fatalError(const SAXParseException& toCatch)
    {
	_sawErrors = true;
	::std::cerr << "Fatal at file \"" << DOMString(toCatch.getSystemId())
		    << "\", line " << toCatch.getLineNumber()
		    << ", column " << toCatch.getColumnNumber()
		    << "\n   Message: " << DOMString(toCatch.getMessage()) << ::std::endl;
    }

    void resetErrors()
    {
    }

    bool getSawErrors() const { return _sawErrors; }

    bool    _sawErrors;
};

#endif