<?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[unbekannte Exception weiterschmeißen]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>wenn ich eine Exception fange, wo ich nicht weiß, von welchem<br />
Typ sie ist, wie kann ich sie dann weiterschmeißen?</p>
<p>Ich dachte an etwas sowas:</p>
<pre><code class="language-cpp">void* ptr=malloc(1024);
try{
    method(); // throws any Exception
}
catch(KnownException e){
    free(ptr);
}
catch(...){
    free(ptr);
    // throw catched Exception
}
</code></pre>
<p>Geht sowas oder muss ich alle potentiellen Exceptions(bzw. eine Basisklasse wie std::exception) kennen?</p>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/158571/unbekannte-exception-weiterschmeißen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 10 Sep 2026 07:40:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/158571.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Sep 2006 15:07:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Wed, 06 Sep 2006 15:07:55 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>wenn ich eine Exception fange, wo ich nicht weiß, von welchem<br />
Typ sie ist, wie kann ich sie dann weiterschmeißen?</p>
<p>Ich dachte an etwas sowas:</p>
<pre><code class="language-cpp">void* ptr=malloc(1024);
try{
    method(); // throws any Exception
}
catch(KnownException e){
    free(ptr);
}
catch(...){
    free(ptr);
    // throw catched Exception
}
</code></pre>
<p>Geht sowas oder muss ich alle potentiellen Exceptions(bzw. eine Basisklasse wie std::exception) kennen?</p>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132423</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132423</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 06 Sep 2006 15:07:55 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Wed, 06 Sep 2006 15:17:18 GMT]]></title><description><![CDATA[<p>Hi!</p>
<p>Einfach:</p>
<pre><code class="language-cpp">try
{ /*...*/ }
catch ( ... )
{ throw; }
</code></pre>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132430</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132430</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Wed, 06 Sep 2006 15:17:18 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Wed, 06 Sep 2006 21:15:38 GMT]]></title><description><![CDATA[<p>warum verwendest du ned nen vector ? der wird automatisch aufgeräumt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132656</guid><dc:creator><![CDATA[ronny]]></dc:creator><pubDate>Wed, 06 Sep 2006 21:15:38 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Wed, 06 Sep 2006 23:38:08 GMT]]></title><description><![CDATA[<p>Wieso wird nen Vector automatisch aufgeräumt?</p>
<p>Ist der von std::autoptr abgeleitet?</p>
<p>Oder wie krieg ich das für eigene Datentypen hin, dass die selbst aufgeräumt werden?</p>
<p>Gruß,<br />
Vectorianer</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132682</guid><dc:creator><![CDATA[Vectorianer]]></dc:creator><pubDate>Wed, 06 Sep 2006 23:38:08 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Thu, 07 Sep 2006 00:02:16 GMT]]></title><description><![CDATA[<p>Vectorianer schrieb:</p>
<blockquote>
<p>Wieso wird nen Vector automatisch aufgeräumt?</p>
<p>Ist der von std::autoptr abgeleitet?</p>
</blockquote>
<p>Du meinst std::auto_ptr. Aber std::vector ist nicht davon abgeleitet.</p>
<blockquote>
<p>Oder wie krieg ich das für eigene Datentypen hin, dass die selbst aufgeräumt werden?</p>
</blockquote>
<p>Ein eigener Datentyp ist in C++ eine Klasse und die bietet dir einen Destruktor an. Im Destruktor solltest du dann die Resourcen freigeben. Das macht auto_ptr genauso, wie jede andere gut designte Klasse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132686</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Thu, 07 Sep 2006 00:02:16 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Thu, 07 Sep 2006 08:27:09 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich glaube, hier geht einiges durcheinander, weil das Thema &quot;Vector&quot; und &quot;Wieso aufräumen&quot; aufgekommen ist.</p>
<p>Vorweg: Die eigentliche Frage hat David_pb beantwortet. Damit kann der Threadersteller weitermachen.</p>
<p>Der Vorschlag, eine andere Speicherverwelatung zu verwenden, als einen &quot;void* malloc(1024)&quot;, ist wirklich gut .... aber nicht sinnvoll zu bewerten ohne zu wissen, was CSpille eigentlich vorhat.</p>
<p>- vector ist ein gutes Instrument, wenn der Typ vorher bekannt und für alle Elemente identsch ist und man dynamisch Objekte hinzufügen möchte .<br />
- Wenn Letzteres gar nicht notwendig ist, kann ein schlichtes Stackarray genausogute / bessere Dienste leisten.<br />
Mit</p>
<pre><code class="language-cpp">int intArr[1024];
method();
</code></pre>
<p>braucht man sich um &quot;Aufräumen des Speichers&quot; gar nicht mehr zu kümmern.<br />
Allerdings muß der Typ vorher bekannt sein ud für alle identisch sein.<br />
- braucht man wirklich &quot;nackten Speicher&quot; (z.B. bei der lowlevel-Kommunikation), ist ein malloc/free gar nicht so schlecht.<br />
- ....</p>
<p>Es gibt zahllose andere Möglichkeiten, zwischen denen man aber nur entscheiden kann, wenn die Verwendung klar ist.</p>
<p>Gruß,</p>
<p>Simon2.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132759</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132759</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Thu, 07 Sep 2006 08:27:09 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Thu, 07 Sep 2006 09:47:06 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>Ich habe zur Vereinfachung in das malloc einen festen Wert reingeschrieben,<br />
allerdings soll es in meinem Fall eine Variable sein.<br />
und Arrays mit Variabler Größe sind doch afaik nicht möglich oder hab ich<br />
da was falsches in Erinnerung?<br />
Ich kann es im Moment auch nicht testen, da ich an einem anderen Rechner sitze...<br />
Aber mit dem Vektor muss ich euch recht geben, ist schon praktisch, da der Destruktor den ganzen Platz wieder freigibt.</p>
<p>Gruß,<br />
CSpille</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132833</guid><dc:creator><![CDATA[CSpille (off)]]></dc:creator><pubDate>Thu, 07 Sep 2006 09:47:06 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Thu, 07 Sep 2006 11:03:43 GMT]]></title><description><![CDATA[<p>die template klasse vector ist das array mit variabler größe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132895</guid><dc:creator><![CDATA[ronny]]></dc:creator><pubDate>Thu, 07 Sep 2006 11:03:43 GMT</pubDate></item><item><title><![CDATA[Reply to unbekannte Exception weiterschmeißen on Thu, 07 Sep 2006 11:12:44 GMT]]></title><description><![CDATA[<p>r0nny schrieb:</p>
<blockquote>
<p>die template klasse vector ist das array mit variabler größe</p>
</blockquote>
<p>Wenn wir schonmal dabei sind. Template Klasse is irgendwie eine doofe Bezeichnung! Sollte eher Klassen Template heissen. :)))</p>
<p>grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1132906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1132906</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Thu, 07 Sep 2006 11:12:44 GMT</pubDate></item></channel></rss>