Safir SDK Core
Loading...
Searching...
No Matches
ParseError.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2004-2015 (http://safirsdkcore.com)
4*
5* Created by: Joel Ottosson / joot
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more Internals.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24#ifndef __DOTS_INTERNAL_PARSE_ERROR_H__
25#define __DOTS_INTERNAL_PARSE_ERROR_H__
26
27#include <sstream>
28#include <Safir/Dob/Typesystem/ToolSupport/Internal/InternalExportDefs.h>
29
30namespace Safir
31{
32namespace Dob
33{
34namespace Typesystem
35{
36namespace ToolSupport
37{
38
39#ifdef _MSC_VER
40#pragma warning (push)
41#pragma warning (disable: 4275)
42#pragma warning (disable: 4251)
43#endif
44
48 class DOTS_INTERNAL_API ParseError : public std::exception
49 {
50 public:
51
60 ParseError(const std::string& label, const std::string& description, const std::string& file, int errorId)
61 :m_label(label)
62 ,m_description(description)
63 ,m_file(file)
64 ,m_what()
65 ,m_errorId(errorId)
66 {
67 }
68
72 ~ParseError() throw() {}
73
79 const std::string& Label() const throw() {return m_label;}
80
86 const std::string& Description() const throw() {return m_description;}
87
93 const std::string& File() const throw() {return m_file;}
94
101 int ErrorId() const {return m_errorId;}
102
109 const char* what () const throw () override
110 {
111 if (m_what.empty())
112 {
113 std::ostringstream os;
114 os<<m_label<<"; "<<m_description<<"; "<<m_file<<"; ErrorCode="<<m_errorId;
115 m_what=os.str(); //composed error info
116 }
117 return m_what.c_str();
118 }
119
120 private:
121 std::string m_label;
122 std::string m_description;
123 std::string m_file;
124 mutable std::string m_what;
125 int m_errorId;
126 };
127
128#ifdef _MSC_VER
129#pragma warning (pop)
130#endif
131
132}
133}
134}
135} //end namespace Safir::Dob::Typesystem::ToolSupport
136
137#endif
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
Exception used to report errors in dou- and dom- files.
Definition ParseError.h:49
ParseError(const std::string &label, const std::string &description, const std::string &file, int errorId)
Constructor - Creates a ParseError object.
Definition ParseError.h:60
const char * what() const override
Get error informtation on the form "Label; Description; File; ErrorId".
Definition ParseError.h:109
const std::string & File() const
Get file where error occured.
Definition ParseError.h:93
const std::string & Description() const
Get Internaled error description.
Definition ParseError.h:86
int ErrorId() const
Get an error identifier that can be used to find out exactly where this error was generated.
Definition ParseError.h:101
~ParseError()
Destructor.
Definition ParseError.h:72
const std::string & Label() const
Get short error description.
Definition ParseError.h:79