File indexing completed on 2024-04-28 05:42:10

0001 /*
0002  * Port for usage with qt-framework and development for kdesvn
0003  * Copyright (C) 2005-2009 by Rajko Albrecht (ral@alwins-world.de)
0004  * https://kde.org/applications/development/org.kde.kdesvn
0005  */
0006 /*
0007  * ====================================================================
0008  * Copyright (c) 2002-2005 The RapidSvn Group.  All rights reserved.
0009  * dev@rapidsvn.tigris.org
0010  *
0011  * This library is free software; you can redistribute it and/or
0012  * modify it under the terms of the GNU Lesser General Public
0013  * License as published by the Free Software Foundation; either
0014  * version 2.1 of the License, or (at your option) any later version.
0015  *
0016  * This library is distributed in the hope that it will be useful,
0017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0019  * Lesser General Public License for more details.
0020  *
0021  * You should have received a copy of the GNU Lesser General Public
0022  * License along with this library (in the file LGPL.txt); if not,
0023  * write to the Free Software Foundation, Inc., 51 Franklin St,
0024  * Fifth Floor, Boston, MA  02110-1301  USA
0025  *
0026  * This software consists of voluntary contributions made by many
0027  * individuals.  For exact contribution history, see the revision
0028  * history and logs, available at http://rapidsvn.tigris.org/.
0029  * ====================================================================
0030  */
0031 
0032 #ifndef SVNQT_EXCEPTION_H
0033 #define SVNQT_EXCEPTION_H
0034 
0035 #include <svnqt/svnqt_defines.h>
0036 
0037 // subversion api
0038 #include <QString>
0039 #include <svn_client.h>
0040 
0041 namespace svn
0042 {
0043 
0044 /**
0045  * Generic exception class.
0046  */
0047 class SVNQT_EXPORT Exception
0048 {
0049 public:
0050     /**
0051      * Constructor.  Assigns the exception reason.
0052      */
0053     explicit Exception(const char *message) throw();
0054     explicit Exception(const QString &message) throw();
0055 
0056     virtual ~Exception() throw();
0057 
0058     /**
0059      * @return the exception message.
0060      */
0061     virtual const QString &msg() const;
0062 
0063     /**
0064      * @return the outermost error code.
0065      */
0066     apr_status_t apr_err() const;
0067 
0068     static QString error2msg(svn_error_t *error);
0069 
0070 protected:
0071     struct Data;
0072     Data *m;
0073     void setMessage(const QString &);
0074 
0075 private:
0076     Exception(const Exception &) throw();
0077 
0078     Exception() throw();
0079 
0080     Exception &operator=(const Exception &);
0081 };
0082 
0083 /**
0084  * Subversion client exception class.
0085  */
0086 class SVNQT_EXPORT ClientException : public Exception
0087 {
0088 public:
0089     /**
0090      * Constructor.  Sets the error template and an optional message.
0091      * @param error the error to display. This will get cleared inside with svn_error_clear
0092      * so it isn't usable after that!
0093      */
0094     explicit ClientException(svn_error_t *error) throw();
0095 
0096     /**
0097      * Constructor that takes only an apr errorcode
0098      */
0099     explicit ClientException(apr_status_t status) throw();
0100 
0101     /**
0102      * Constructor
0103      */
0104     explicit ClientException(const char *msg) throw();
0105 
0106     /**
0107      * Constructor
0108      */
0109     explicit ClientException(const QString &message) throw();
0110 
0111     /**
0112      * Copy constructor
0113      */
0114     ClientException(const ClientException &src) throw();
0115 
0116     virtual ~ClientException() throw();
0117 
0118 private:
0119     ClientException() throw();
0120 
0121     ClientException &operator=(ClientException &);
0122     static QString getBackTrace();
0123 
0124     void init();
0125     /// backtrace from constructor;
0126     QString m_backTraceConstr;
0127 };
0128 
0129 }
0130 
0131 #endif
0132 /* -----------------------------------------------------------------
0133  * local variables:
0134  * eval: (load-file "../../rapidsvn-dev.el")
0135  * end:
0136  */