aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/parser/error-handler.txx
blob: db247a7131562383cf037e5986a96a7f0dcc0009 (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
// file      : xsd/cxx/parser/error-handler.txx
// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

namespace xsd
{
  namespace cxx
  {
    namespace parser
    {
      template <typename C>
      bool error_handler<C>::
      handle (const std::basic_string<C>& id,
              unsigned long line,
              unsigned long column,
              severity s,
              const std::basic_string<C>& message)
      {
        diagnostics_.push_back (
          error<C> (s == severity::warning
                    ? cxx::parser::severity::warning
                    : cxx::parser::severity::error,
                    id, line, column, message));

        if (!failed_ && s != severity::warning)
          failed_ = true;

        return true;
      }

      template <typename C>
      void error_handler<C>::
      throw_if_failed () const
      {
        if (failed_)
          throw parsing<C> (diagnostics_);
      }
    }
  }
}