trikRuntime
failedToOpenFileException.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 <QFile>
18 #include <QFileInfo>
19 #include <QsLog.h>
20 
21 #include "trikRuntimeException.h"
22 
23 namespace trikKernel {
24 
27 {
28 public:
31  explicit FailedToOpenFileException(const QFile &file)
32  : mFile(file)
33  {
34  QLOG_ERROR() << "Failed to open" << QFileInfo(file).absolutePath()
35  << (file.openMode() & QIODevice::WriteOnly ? "for writing" : "for reading");
36  }
37 
39  const QFile &file() const
40  {
41  return mFile;
42  }
43 
44 private:
45  const QFile &mFile;
46 };
47 
48 }
Definition: analogSensor.h:23
#define QLOG_ERROR()
Definition: QsLog.h:104
FailedToOpenFileException(const QFile &file)
Constructor.
Definition: failedToOpenFileException.h:31
Base class for all exceptions in TRIKRuntime.
Definition: trikRuntimeException.h:22
Exception that is thrown when file opening operation failed.
Definition: failedToOpenFileException.h:26
const QFile & file() const
Returns file that is failed to open.
Definition: failedToOpenFileException.h:39