<?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[Fehlerhandling try&#x2F;catch]]></title><description><![CDATA[<p>Hi!<br />
Frage 1: Warum bricht mein Programm ab, anstatt in den catch-Block zu laufen?!</p>
<pre><code>int l_anzahl = 0;
try {
	int l_anzahl = GetPrivateProfileInt(&quot;Anzahl&quot;, &quot;anzahl&quot;, 0, a_inifile );
} catch (...) {
	cout &lt;&lt; &quot;Anzahl konnte nicht ermittelt werden. Ist die appStart.txt vorhanden? &quot; &lt;&lt; a_inifile &lt;&lt; endl;
}
</code></pre>
<p>'...' sollte doch eigentlich alles abfangen.</p>
<p>Frage 2: Wenn ich konkrete Exceptions abfangen möchte, wie bekomme ich heraus, welche in meinem try-Block überhaupt auftreten können?</p>
<p>thx :p</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/181944/fehlerhandling-try-catch</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 11:05:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/181944.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 19 May 2007 09:04:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sat, 19 May 2007 09:04:59 GMT]]></title><description><![CDATA[<p>Hi!<br />
Frage 1: Warum bricht mein Programm ab, anstatt in den catch-Block zu laufen?!</p>
<pre><code>int l_anzahl = 0;
try {
	int l_anzahl = GetPrivateProfileInt(&quot;Anzahl&quot;, &quot;anzahl&quot;, 0, a_inifile );
} catch (...) {
	cout &lt;&lt; &quot;Anzahl konnte nicht ermittelt werden. Ist die appStart.txt vorhanden? &quot; &lt;&lt; a_inifile &lt;&lt; endl;
}
</code></pre>
<p>'...' sollte doch eigentlich alles abfangen.</p>
<p>Frage 2: Wenn ich konkrete Exceptions abfangen möchte, wie bekomme ich heraus, welche in meinem try-Block überhaupt auftreten können?</p>
<p>thx :p</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287827</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287827</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 19 May 2007 09:04:59 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sat, 19 May 2007 09:19:26 GMT]]></title><description><![CDATA[<p>@1: Nicht jeder Fehler äußert sich in einer Exception - manche greifen auch gleich zu härteren Maßnahmen (assert() oder abort()). Worüber genau stolpert denn dein Programm?</p>
<p>@2: Am einfachsten in der Dokumentation der Funktion (bei STL-Funktionen kannst du auch prophylaktisch 'std::exception&amp;' auffangen, MS-Funktionen schmeißen normalerweise Nachkommen von Exception).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1287833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1287833</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sat, 19 May 2007 09:19:26 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sat, 19 May 2007 13:38:29 GMT]]></title><description><![CDATA[<p>Wenn(!) eine Exc. geworfen wird, kann man mit der Ausgabe von what() Einzelheiten anzeigen lassen, z.B.</p>
<pre><code class="language-cpp">...
catch(const std::exception&amp; e) { // Alle C++-Exc.-Klassen erben von exception
  std::cout &lt;&lt; e.what() &lt;&lt; std::endl;
}
</code></pre>
<p>Wie gesagt, wenn. what() ist virtual und (hoffentlich) für abgeleitete Klassen redefiniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288023</guid><dc:creator><![CDATA[Helpie]]></dc:creator><pubDate>Sat, 19 May 2007 13:38:29 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sat, 19 May 2007 16:53:29 GMT]]></title><description><![CDATA[<p>GetPrivateProfileInt wirft keine Exceptions (niemals), daher wirst du auch keine fangen können. Eigentlich ganz einfach.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288118</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 19 May 2007 16:53:29 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sun, 20 May 2007 11:27:37 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>GetPrivateProfileInt wirft keine Exceptions (niemals), daher wirst du auch keine fangen können. Eigentlich ganz einfach.</p>
</blockquote>
<p>OK, dachte ich mir fast, ich bekomme auch einen unerlaubten Speicherzugriff, nur, weil die gesuchte Datei nicht da ist.<br />
Wie auch immer ich den Fall jetzt behandle, ich hatte halt gehofft, dass ich nur die korrekte Exception kennen muss, so alias FileNotFound in Java....</p>
<p>Wie verhindere ich denn an der Stelle den Abbruch, z.B. durch das Fehlen der Datei? Ich vermute mal, dass ich wirklich nur prüfen kann, ob die Daten vorhanden ist. Andere Abbruchursachen kann ich also nicht ohne vorherige Kenntnis abfangen, oder?!<br />
Ich würde schon gern an der Stelle kontrolliert abbrechen und zumindest eine ungefähre Fehlermeldung ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288342</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288342</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 20 May 2007 11:27:37 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sun, 20 May 2007 15:55:53 GMT]]></title><description><![CDATA[<p>GetPrivateProfileInt erzeugt auch keine access violation nur weil eine Datei nicht da ist, sondern liefert stattdessen den übergebenen Defaultwert zurück.<br />
Wenn du eine access violation bekommst liegt das vermutlich daran dass a_inifile Schrott enthält (z.B. nicht nullterminierter String oder sonstwas).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288552</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288552</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 20 May 2007 15:55:53 GMT</pubDate></item><item><title><![CDATA[Reply to Fehlerhandling try&#x2F;catch on Sun, 20 May 2007 16:05:53 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>GetPrivateProfileInt erzeugt auch keine access violation nur weil eine Datei nicht da ist, sondern liefert stattdessen den übergebenen Defaultwert zurück.<br />
Wenn du eine access violation bekommst liegt das vermutlich daran dass a_inifile Schrott enthält (z.B. nicht nullterminierter String oder sonstwas).</p>
</blockquote>
<p>An den Default-Wert hatte ich ja gar nicht mehr gedacht!<br />
Die Access-Violation kommt aber immer dann, wenn ich die Datei auf einen ungültigen Namen umbenenne!<br />
Naja, jetzt teste ich halt vorher, ob sie da ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1288557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1288557</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 20 May 2007 16:05:53 GMT</pubDate></item></channel></rss>