Kross
errorinterface.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * errorinterface.h 00003 * This file is part of the KDE project 00004 * copyright (C)2004-2006 by Sebastian Sauer (mail@dipe.org) 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Library General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this program; see the file COPYING. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 ***************************************************************************/ 00019 00020 #ifndef KROSS_ERRORINTERFACE_H 00021 #define KROSS_ERRORINTERFACE_H 00022 00023 #include "krossconfig.h" 00024 00025 #include <QtCore/QString> 00026 00027 namespace Kross { 00028 00032 class KROSSCORE_EXPORT ErrorInterface 00033 { 00034 public: 00035 00043 ErrorInterface() {} 00044 00048 bool hadError() const { return ! m_error.isNull(); } 00049 00053 const QString errorMessage() const { return m_error; } 00054 00058 const QString errorTrace() const { return m_trace; } 00059 00064 long errorLineNo() const { return m_lineno; } 00065 00069 void setError(const QString& errormessage, const QString& tracemessage = QString(), long lineno = -1) { 00070 m_error = errormessage; 00071 m_trace = tracemessage; 00072 m_lineno = lineno; 00073 krosswarning( QString::fromLatin1("Error error=%1 lineno=%2 trace=\n%3").arg(m_error).arg(m_lineno).arg(m_trace) ); 00074 } 00075 00079 void setError(ErrorInterface* error) { 00080 m_error = error->errorMessage(); 00081 m_trace = error->errorTrace(); 00082 m_lineno = error->errorLineNo(); 00083 } 00084 00088 void clearError() { 00089 m_error.clear(); 00090 m_trace.clear(); 00091 m_lineno = -1; 00092 } 00093 00094 private: 00096 QString m_error; 00098 QString m_trace; 00100 long m_lineno; 00101 }; 00102 00103 } 00104 00105 #endif 00106