<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[eigene Exception Klasse]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine eigene Exception Klasse:</p>
<pre><code class="language-cpp">#ifndef A_EXCEPTION_H
#define	A_EXCEPTION_H

#include &lt;string&gt;
#include &lt;exception&gt;

namespace A {
    namespace B {

        class Exception : public std::exception {

        public:

            Exception(const char* message) {
                m = message;
            }

            virtual ~Exception() throw() {
            };

            const char* toString() {
                return m.c_str();
            }

            const char* what() {
                return m.c_str();
            }

        protected:
            std::string m;

        private:
            Exception();
        };

        class NotImplementedYetException : public Exception {
        public:
            NotImplementedYetException(const char* message):Exception(message){}
        };

        class IndexOutOfBounceException : public Exception {
        public:
            IndexOutOfBounceException(const char* message):Exception(message){}
        };

        class AttributeNotSetException : public Exception {
        public:
            AttributeNotSetException(const char* message):Exception(message){}
        };

        class PeerNotFoundException : public Exception {
        public:
            PeerNotFoundException(const char* message):Exception(message){}
        };

        class ClusterNotFoundException : public Exception {
        public:
            ClusterNotFoundException(const char* message):Exception(message){}
        };

        class PeerPlaceException : public Exception {
        public:
            PeerPlaceException(const char* message):Exception(message){}
        };

        class ClusterLimitReachedException : public PeerPlaceException {
        public:
            ClusterLimitReachedException(const char* message):PeerPlaceException(message){}
        };
    };
};
#endif
</code></pre>
<p>Wenn die Exception aber geworfen wird, bekomme ich in meiner Testumgebung folgende Ausgabe bei What():</p>
<pre><code>N6Ae10B21PeerNotFoundExceptionE
</code></pre>
<p>Wie bekomme ich dies gefixt?</p>
<p>Gruß, Uwe</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/270212/eigene-exception-klasse</link><generator>RSS for Node</generator><lastBuildDate>Sun, 30 Aug 2026 12:51:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270212.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Jul 2010 11:03:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:03:41 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine eigene Exception Klasse:</p>
<pre><code class="language-cpp">#ifndef A_EXCEPTION_H
#define	A_EXCEPTION_H

#include &lt;string&gt;
#include &lt;exception&gt;

namespace A {
    namespace B {

        class Exception : public std::exception {

        public:

            Exception(const char* message) {
                m = message;
            }

            virtual ~Exception() throw() {
            };

            const char* toString() {
                return m.c_str();
            }

            const char* what() {
                return m.c_str();
            }

        protected:
            std::string m;

        private:
            Exception();
        };

        class NotImplementedYetException : public Exception {
        public:
            NotImplementedYetException(const char* message):Exception(message){}
        };

        class IndexOutOfBounceException : public Exception {
        public:
            IndexOutOfBounceException(const char* message):Exception(message){}
        };

        class AttributeNotSetException : public Exception {
        public:
            AttributeNotSetException(const char* message):Exception(message){}
        };

        class PeerNotFoundException : public Exception {
        public:
            PeerNotFoundException(const char* message):Exception(message){}
        };

        class ClusterNotFoundException : public Exception {
        public:
            ClusterNotFoundException(const char* message):Exception(message){}
        };

        class PeerPlaceException : public Exception {
        public:
            PeerPlaceException(const char* message):Exception(message){}
        };

        class ClusterLimitReachedException : public PeerPlaceException {
        public:
            ClusterLimitReachedException(const char* message):PeerPlaceException(message){}
        };
    };
};
#endif
</code></pre>
<p>Wenn die Exception aber geworfen wird, bekomme ich in meiner Testumgebung folgende Ausgabe bei What():</p>
<pre><code>N6Ae10B21PeerNotFoundExceptionE
</code></pre>
<p>Wie bekomme ich dies gefixt?</p>
<p>Gruß, Uwe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923202</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923202</guid><dc:creator><![CDATA[uwerothfeld_]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:10:07 GMT]]></title><description><![CDATA[<p>Dann zeige mal wie du die Exception wirfst und fängst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923204</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:10:07 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:40:16 GMT]]></title><description><![CDATA[<p>Hallo Theta,</p>
<p>also werfen zum Beispiel so:</p>
<pre><code class="language-cpp">Peer &amp; Group::getPeer(PeerID pId){ 

            for(size_t i = 0; i &lt; clusterList.size(); i++){

                Cluster c = clusterList.get(i);

                if(c.contains(pId)){
                    return c.getPeer(pId);
                }//End if

            }//End for

            throw PeerNotFoundException(&quot;given peer not in list&quot;);

        }//End getPeer
</code></pre>
<p>Fangen überlasse ich CppUnit <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
Gruß, Uwe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923221</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923221</guid><dc:creator><![CDATA[uwerothfeld_]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:40:16 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:43:58 GMT]]></title><description><![CDATA[<p>aha.. und hast du nicht weiter gelesen? fangen auch noch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923224</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:43:58 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:49:16 GMT]]></title><description><![CDATA[<p>Die Signatur deiner what-Funktion ist falsch:</p>
<p>virtual const char* what() const throw()</p>
<p>Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923226</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:49:16 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 11:55:00 GMT]]></title><description><![CDATA[<p>Hallo Theta,</p>
<p>na wenn ich es selber fange, dann so:</p>
<pre><code class="language-cpp">try{
        Peer p = c.getPeer(2);
    }
    catch(A::B::PeerNotFoundException e){
        std::cout&lt;&lt;&quot;Upps: &quot;&lt;&lt;e.what()&lt;&lt;std::endl;
    }
</code></pre>
<p>So kommt dann ne schöne Ausgabe ala &quot;Upps: peer not in list&quot;. Aber wenn es halt nicht gefangen wird von mir, oder einem Framework wie CppUnitTest, sieht es aus, wie beschrieben.<br />
Oder kann man da nix ändern? Kann es sein, dass meine what falsch deklariert ist? Muss ich die vielleicht ändern?</p>
<p>Gruß und Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923233</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923233</guid><dc:creator><![CDATA[uwerothfeld_]]></dc:creator><pubDate>Thu, 08 Jul 2010 11:55:00 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 12:16:48 GMT]]></title><description><![CDATA[<p>Exceptions besser per Referenz fangen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923247</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 08 Jul 2010 12:16:48 GMT</pubDate></item><item><title><![CDATA[Reply to eigene Exception Klasse on Thu, 08 Jul 2010 12:47:46 GMT]]></title><description><![CDATA[<p>Ah!</p>
<p>Der manni hatte Recht. Die falsche Signatur war der Grund! Sehr schön, sehr schön <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Vielen Dank für Eure Hilfe! Fall Gelöst!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1923278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1923278</guid><dc:creator><![CDATA[uwerothfeld_]]></dc:creator><pubDate>Thu, 08 Jul 2010 12:47:46 GMT</pubDate></item></channel></rss>