<?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[Ausnahmebehandlung - Parameter übergeben?]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe in C++ folgende Ausnahmebehandlung...</p>
<pre><code class="language-cpp">int main(int argc, char **argv) try {

  //irgendwo im Programm:
  int number = 99;
  throw &quot;parsing failed; stopped at&quot; + number;

}
catch (out_of_range const&amp; oor) {
	cerr &lt;&lt; argv[0] &lt;&lt; &quot;: &quot; &lt;&lt; oor.what() &lt;&lt; endl;
	return 1;
}
catch(???????) {

}
</code></pre>
<p>Das Zusammensetzen des String funktioniert aber nicht, also &quot;parsing failed; stopped at&quot; + number ! wie kann ich die Exception schreiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/239078/ausnahmebehandlung-parameter-übergeben</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 14:50:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/239078.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Apr 2009 08:52:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausnahmebehandlung - Parameter übergeben? on Sun, 19 Apr 2009 08:52:24 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe in C++ folgende Ausnahmebehandlung...</p>
<pre><code class="language-cpp">int main(int argc, char **argv) try {

  //irgendwo im Programm:
  int number = 99;
  throw &quot;parsing failed; stopped at&quot; + number;

}
catch (out_of_range const&amp; oor) {
	cerr &lt;&lt; argv[0] &lt;&lt; &quot;: &quot; &lt;&lt; oor.what() &lt;&lt; endl;
	return 1;
}
catch(???????) {

}
</code></pre>
<p>Das Zusammensetzen des String funktioniert aber nicht, also &quot;parsing failed; stopped at&quot; + number ! wie kann ich die Exception schreiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1698023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1698023</guid><dc:creator><![CDATA[Dax]]></dc:creator><pubDate>Sun, 19 Apr 2009 08:52:24 GMT</pubDate></item><item><title><![CDATA[Reply to Ausnahmebehandlung - Parameter übergeben? on Sun, 19 Apr 2009 09:19:38 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">catch(char const *str)
</code></pre>
<p>iirc. Aber es ist sinnvoller dafür eine eigene Exceptionklasse zu nutzen</p>
<pre><code class="language-cpp">struct parsing_exception : std::runtime_error {
  parsing_exception(std::string const &amp;str) : std::runtime_error(str) { }
};

int main() try {
  throw parsing_exception(&quot;foo&quot;);
}
catch(std::exception const &amp;e) {
  std::cerr &lt;&lt; &quot;Error: &quot; &lt;&lt; e.what() &lt;&lt; '\n';
}
</code></pre>
<p>dann kann man nämlich gezielter catchen.</p>
<p>btw. achso &quot;string&quot;+int-Funktioniert so in C++ natürlich auch nicht!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1698034</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1698034</guid><dc:creator><![CDATA[rüdiger]]></dc:creator><pubDate>Sun, 19 Apr 2009 09:19:38 GMT</pubDate></item><item><title><![CDATA[Reply to Ausnahmebehandlung - Parameter übergeben? on Sun, 19 Apr 2009 09:20:46 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-1819.html" rel="nofollow">rüdiger</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-8.html" rel="nofollow">Rund um die Programmierung</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1698035</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1698035</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sun, 19 Apr 2009 09:20:46 GMT</pubDate></item><item><title><![CDATA[Reply to Ausnahmebehandlung - Parameter übergeben? on Sun, 19 Apr 2009 12:37:29 GMT]]></title><description><![CDATA[<p>Dax schrieb:</p>
<blockquote>
<p>Das Zusammensetzen des String funktioniert aber nicht, also &quot;parsing failed; stopped at&quot; + number ! wie kann ich die Exception schreiben?</p>
</blockquote>
<p>Du kannst keinen <code>const char*</code> zu einem <code>int</code> addieren. Schau mal in <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-239011.html" rel="nofollow">diesem Thread</a> nach, dort habe ich eine Lösung gepostet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1698139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1698139</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 19 Apr 2009 12:37:29 GMT</pubDate></item></channel></rss>