WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZblError.cpp
Go to the documentation of this file.
1 /*
2  * Zuble - A run-time system for QML/Javascript applications
3  * Copyright (C) 2013, 2014 Bob Dinitto
4  *
5  * ZblError.cpp
6  *
7  * Created on: Feb 3, 2013
8  * Author: Bob Dinitto bob@ninzo.com
9  *
10  * Zuble is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library 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 GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24 */
25 
26 #include "ZblError.h"
27 //#include "ZApplication.h"
28 
29 namespace Zbl
30 {
31 
32 const QString ZblError::m_defaultFacility = "Z"; // Z as in Zuble
33 const QString ZblError:: m_defaultCode = "0"; // the digit zero
34 const QString ZblError::m_defaultMessage = "K"; // K as in OK
35 
37 {
38  clear();
39 }
40 
42 {
43  m_facility = err.m_facility;
44  m_code = err.m_code;
45  m_message = err.m_message;
46  m_hasError = err.m_hasError;
47 }
48 
49 
51  const QString& facility,
52  const QString& code,
53  const QString& message
54  )
55 {
57  m_code = code;
58 
59  m_message += "[";
60  m_message += message;
61  m_message += "]";
62  m_hasError = true;
63 }
64 
66  const char* facility,
67  const char* code,
68  const char* message
69  )
70 {
72  m_code = code;
73 
74  m_message += "[";
75  m_message += message;
76  m_message += "]";
77  m_hasError = true;
78 }
79 
81 {
85  m_hasError = false;
86 }
87 
88 
89 const QString& ZblError::facility() const
90 {
91  return m_facility;
92 }
93 
94 const QString& ZblError::code() const
95 {
96  return m_code;
97 }
98 
99 const QString& ZblError::message() const
100 {
101  return m_message;
102 }
103 
104 const QString ZblError::description() const
105 {
106  return QString("%1:%2:%3")
107  .arg(m_facility)
108  .arg(m_code)
109  .arg(m_message);
110 }
111 
112 bool ZblError::isError() const
113 {
114  return m_hasError;
115 }
116 
117 bool ZblError::isOK() const
118 {
119  return !m_hasError;
120 }
121 
122 
123 } // Zbl
bool isOK() const
Definition: ZblError.cpp:117
bool m_hasError
Definition: ZblError.h:81
static const QString m_defaultFacility
Definition: ZblError.h:77
const QString & code() const
Definition: ZblError.cpp:94
const QString & facility() const
Definition: ZblError.cpp:89
void set(const QString &facility, const QString &code, const QString &message)
Definition: ZblError.cpp:50
Definition: ZAndGate.cpp:6
QString m_code
Definition: ZblError.h:74
static const QString m_defaultMessage
Definition: ZblError.h:79
Data object for thread local error status information.
Definition: ZblError.h:41
const QString & message() const
Definition: ZblError.cpp:99
bool isError() const
Definition: ZblError.cpp:112
QString m_message
Definition: ZblError.h:75
void clear()
Definition: ZblError.cpp:80
const QString description() const
Definition: ZblError.cpp:104
QString m_facility
Definition: ZblError.h:73
static const QString m_defaultCode
Definition: ZblError.h:78