BPS C++ API  2.24.4
bpsexception.h
Go to the documentation of this file.
1 
4 #ifndef BPSEXCEPTION_H
5 #define BPSEXCEPTION_H
6 
7 #include "bpscore_global.h"
8 #include <QString>
9 #include <QScriptValue>
10 
11 class QScriptContext;
12 
31 {
33 
34 public:
38  enum Severity {
39  Info,
42  Fatal
43  };
44 
50 
55  BpsException(const BpsException& aException);
56 
75  BpsException(const QString& aFilename, quint32 aLinenumber, const QString& aFunction, const QString& aMessage, Severity aSeverity);
76 
82  BpsException(const QScriptValue& aException, const QString& aFilename = QString());
83 
84  virtual ~BpsException();
85 
91  BpsException& setMessage(const QString& aMessage);
92 
99 
106 
132  BpsException& addLocation(const QString& aFilename, quint32 aLinenumber, const QString& aFunction);
133 
138  QString message() const;
139 
145 
174  QString text(int aMaxLocs = 1) const;
175 
202  QScriptValue throwScriptError(QScriptContext* aContext) const;
203 
204 };
205 
213 #define bpsMakeException(aMessage) BpsException(__FILE__, __LINE__, QString::fromLatin1(__FUNCTION__), aMessage, BpsException::Error)
214 
222 #define bpsMakeExceptionWarning(aMessage) BpsException(__FILE__, __LINE__, QString::fromLatin1(__FUNCTION__), aMessage, BpsException::Warning)
223 
231 #define bpsMakeExceptionInfo(aMessage) BpsException(__FILE__, __LINE__, QString::fromLatin1(__FUNCTION__), aMessage, BpsException::Info)
232 
241 #define bpsMakeExceptionFatal(aMessage) BpsException(__FILE__, __LINE__, QString::fromLatin1(__FUNCTION__), aMessage, BpsException::Fatal)
242 
250 #define bpsTraceException(aException) aException.addLocation(__FILE__, __LINE__, QString::fromLatin1(__FUNCTION__))
251 
252 #endif // BPSEXCEPTION_H
Public include file for BPS CORE library macros.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
BPS error exception class.
Definition: bpsexception.h:31
QString message() const
Get the plain message, without location trace information.
BpsException & addLocation(const QString &aFilename, quint32 aLinenumber, const QString &aFunction)
Add another location to an existing exception.
BpsException & appendMessage(const QString &aText)
Append text to the error message of the exception.
BpsException(const QScriptValue &aException, const QString &aFilename=QString())
Constructor from QtScript exceptions.
BpsException & setSeverity(Severity aSeverity)
Set the error severity for the exception.
BpsException()
Default constructor for the BpsException objects.
BpsException & setMessage(const QString &aMessage)
Set the error message for the exception.
QScriptValue throwScriptError(QScriptContext *aContext) const
Throw a script error of the exception.
Severity severity() const
Get severity.
QString text(int aMaxLocs=1) const
Get the message, along with a log of the locations stack.
Severity
Severity of the exception.
Definition: bpsexception.h:38
@ Warning
Uncritical, retry later for example.
Definition: bpsexception.h:40
@ Error
Critical error.
Definition: bpsexception.h:41
@ Info
Information, debug stop for example.
Definition: bpsexception.h:39
BpsException(const BpsException &aException)
Copy constructor for the BpsException objects.
BpsException(const QString &aFilename, quint32 aLinenumber, const QString &aFunction, const QString &aMessage, Severity aSeverity)
Standard constructor for the BpsException objects.