trikRuntime
failedToParseXmlException.h
Go to the documentation of this file.
1 /* Copyright 2015 CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QFile>
18 #include <QtCore/QString>
19 
20 #include <QsLog.h>
21 
22 #include "trikRuntimeException.h"
23 
24 namespace trikKernel {
25 
28 {
29 public:
35  FailedToParseXmlException(const QFile &file, const QString &errorMessage, int errorLine, int errorColumn)
36  : mFile(file), mErrorMessage(errorMessage), mErrorLine(errorLine), mErrorColumn(errorColumn)
37  {
38  QLOG_ERROR() << QString("Failed to parse %1, %2:%3 - %4")
39  .arg(file.fileName())
40  .arg(errorLine)
41  .arg(errorColumn)
42  .arg(errorMessage);
43  }
44 
46  const QFile &file() const
47  {
48  return mFile;
49  }
50 
52  QString errorMessage() const
53  {
54  return mErrorMessage;
55  }
56 
58  int errorLine() const
59  {
60  return mErrorLine;
61  }
62 
64  int errorColumn() const
65  {
66  return mErrorColumn;
67  }
68 
69 private:
70  const QFile &mFile;
71  const QString mErrorMessage;
72  const int mErrorLine;
73  const int mErrorColumn;
74 };
75 
76 }
QString errorMessage() const
Returns error message.
Definition: failedToParseXmlException.h:52
Definition: analogSensor.h:23
#define QLOG_ERROR()
Definition: QsLog.h:104
Base class for all exceptions in TRIKRuntime.
Definition: trikRuntimeException.h:22
const QFile & file() const
Returns XML file that is failed to parse.
Definition: failedToParseXmlException.h:46
FailedToParseXmlException(const QFile &file, const QString &errorMessage, int errorLine, int errorColumn)
Constructor.
Definition: failedToParseXmlException.h:35
int errorLine() const
Returns line in XML document where error occured.
Definition: failedToParseXmlException.h:58
int errorColumn() const
Returns column in XML document where error occured.
Definition: failedToParseXmlException.h:64
Exception that is thrown when XML file is corrupt and "setContent" method of QDomDocument has failed...
Definition: failedToParseXmlException.h:27