<?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[Datengröße für std::exception ändern]]></title><description><![CDATA[<p>Hallo,</p>
<p>gibt's irgendwo einen Schalter, mit dem man einstellen kann, wie viel<br />
Text man einer Exception mitgeben kann?</p>
<p>irgendwie ist da nach 255 Zeichen Feierabend <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":-("
      alt="😞"
    /></p>
<p>Bsp:</p>
<pre><code class="language-cpp">char myMessage[] = &quot;ein schöner langer Text länger als 255 Zeichen... &quot;;
throw (std::runtime_error(myMessage));

...

catch(std::exception &amp; Ex)
{
// hier kommen von nur ca. 255 Zeichen an
// (habs ned genau gezählt aber ich vermute mal wegen \0 nicht 256)
std::cout&lt;&lt;Ex.what()&lt;&lt;std::endl;
}
</code></pre>
<p>Wäre schön, wenns da eine Möglichkeit gäbe,<br />
weil ich erst vor kurzem von eigenen Exception-Objekten<br />
auf std::exception umgestellt hab.<br />
(Wär dann ziemlich für die Katz gewesen ...)</p>
<p>Danke<br />
Martin</p>
<p>PS:<br />
Warum so ein langer Text?<br />
Ist für eine Datenbankanbindung,<br />
soll Anfrage + Datenbankfehlermeldung ausspucken.</p>
<p>Da kommen schon mal mehr als 255 Zeichen dabei raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/118260/datengröße-für-std-exception-ändern</link><generator>RSS for Node</generator><lastBuildDate>Fri, 21 Aug 2026 09:20:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118260.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 16 Aug 2005 19:33:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 19:33:21 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>gibt's irgendwo einen Schalter, mit dem man einstellen kann, wie viel<br />
Text man einer Exception mitgeben kann?</p>
<p>irgendwie ist da nach 255 Zeichen Feierabend <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":-("
      alt="😞"
    /></p>
<p>Bsp:</p>
<pre><code class="language-cpp">char myMessage[] = &quot;ein schöner langer Text länger als 255 Zeichen... &quot;;
throw (std::runtime_error(myMessage));

...

catch(std::exception &amp; Ex)
{
// hier kommen von nur ca. 255 Zeichen an
// (habs ned genau gezählt aber ich vermute mal wegen \0 nicht 256)
std::cout&lt;&lt;Ex.what()&lt;&lt;std::endl;
}
</code></pre>
<p>Wäre schön, wenns da eine Möglichkeit gäbe,<br />
weil ich erst vor kurzem von eigenen Exception-Objekten<br />
auf std::exception umgestellt hab.<br />
(Wär dann ziemlich für die Katz gewesen ...)</p>
<p>Danke<br />
Martin</p>
<p>PS:<br />
Warum so ein langer Text?<br />
Ist für eine Datenbankanbindung,<br />
soll Anfrage + Datenbankfehlermeldung ausspucken.</p>
<p>Da kommen schon mal mehr als 255 Zeichen dabei raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853672</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Tue, 16 Aug 2005 19:33:21 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 19:54:34 GMT]]></title><description><![CDATA[<p>Welchen Compiler benutzt du denn? Bei Visual C++ 2003 geht mehr. (ich denke unbegrenzt) Habs mit 385 ausprobiert.<br />
Guck doch mal in die Header-Datei exception, da müsste das doch implementiert sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853679</guid><dc:creator><![CDATA[denker]]></dc:creator><pubDate>Tue, 16 Aug 2005 19:54:34 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 20:16:29 GMT]]></title><description><![CDATA[<p>Da std::exception::what() virtual ist, kannst du doch diese ganz einfach überschreiben.</p>
<p>Machste sowas hier:</p>
<pre><code class="language-cpp">class sql_exception : public std::exception {
public:
  	sql_exception(){
        }
	sql_exception(const char *msg) {
            my_what = msg;
        }
        sql_exception(const std::string &amp;msg) {
           my_what = msg;
        }

        virtual const char *what() const {
            return my_what.c_str();
        }
private:
   std::string my_what;
};
</code></pre>
<p>Jetzt kannste unendlich lange Texte raushauen. Am besten du machst aber eine allgemeinere exception, die du für alle deine Exceptions benutzen kannst, die hier ist jetzt natürlich speziell für dein eines Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853691</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853691</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Tue, 16 Aug 2005 20:16:29 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 20:19:34 GMT]]></title><description><![CDATA[<p>Achja, da zeigt sich mal wieder das Problem, wenn man auf std::string verzichtet, weil es _angeblich_ mit Kanonen auf Spatzen geschossen ist. Es rächt sich irgendwann!!! Genauso wie wenn einige hier anstatt vector noch auf normale Arrays schwören.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853694</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Tue, 16 Aug 2005 20:19:34 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 21:22:39 GMT]]></title><description><![CDATA[<p>also ich seh gerade unter visual c++ arbeitet std::runtime_error mit std::string:</p>
<p><a href="http://www.rafb.net/paste/results/xviWBQ22.html" rel="nofollow">http://www.rafb.net/paste/results/xviWBQ22.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/853727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853727</guid><dc:creator><![CDATA[denker]]></dc:creator><pubDate>Tue, 16 Aug 2005 21:22:39 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 21:39:49 GMT]]></title><description><![CDATA[<p>Artchi schrieb:</p>
<blockquote>
<p>Achja, da zeigt sich mal wieder das Problem, wenn man auf std::string verzichtet, weil es _angeblich_ mit Kanonen auf Spatzen geschossen ist. Es rächt sich irgendwann!!! Genauso wie wenn einige hier anstatt vector noch auf normale Arrays schwören.</p>
</blockquote>
<p>das problem ist einfach, dass std::string selber durch new eine exception schmeissen kann, und wenn das passiert während grad eine exception geworfen wird, macht dein gesamtes programm einen abgang.</p>
<p>von daher würd ich bei kritischen ausnahmen einen char buffer[256] favorisieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/853738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853738</guid><dc:creator><![CDATA[otze]]></dc:creator><pubDate>Tue, 16 Aug 2005 21:39:49 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Tue, 16 Aug 2005 21:43:11 GMT]]></title><description><![CDATA[<p>@denker: sehr klug: &quot;Posts expire after 24 hours. &quot; <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>packs doch hier ins forum:</p>
<pre><code class="language-cpp">class runtime_error
	: public _XSTD exception
	{	// base of all runtime-error exceptions
public:
	explicit runtime_error(const string&amp; _Message)
		: _Str(_Message)
		{	// construct from message string
		}

	virtual ~runtime_error()
		{}	// destroy the object

	virtual const char *what() const _THROW0()
		{	// return pointer to message string
		return (_Str.c_str());
		}

 #if !_HAS_EXCEPTIONS
protected:
	virtual void _Doraise() const
		{	// perform class-specific exception handling
		_RAISE(*this);
		}
 #endif /* _HAS_EXCEPTIONS */

private:
	string _Str;	// the stored message string
	};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/853743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853743</guid><dc:creator><![CDATA[Cpt.Tanga]]></dc:creator><pubDate>Tue, 16 Aug 2005 21:43:11 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 09:40:23 GMT]]></title><description><![CDATA[<p>denker  schrieb:</p>
<blockquote>
<p>Welchen Compiler benutzt du denn?</p>
</blockquote>
<p>Hab hier den Borland Compiler 5.6.4 (der beim C++Builder X Personal dabei ist).</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/1463">@Artchi</a>:<br />
Ableiten funktioniert wunderbestens unter obigem Compiler.</p>
<p>Allerdings spuckt mir der gcc einen haufen Fehler aus,<br />
mit denen ich ned wirklich viel anfangen kann...</p>
<pre><code>&quot;mqlException.hpp&quot;: files/include/mql/mqlException.hpp looser throw specifier for `virtual in Zeile 10
MQL::EXCEPTION::~EXCEPTION()'
&quot;exception&quot;: C:/Programme/compInt/cbx/mingw/include/c++/3.2/exception overriding ` in Zeile 54
virtual std::exception::~exception() throw ()'
&quot;mqlException.hpp&quot;: files/include/mql/mqlException.hpp looser throw specifier for `virtual in Zeile 12
const char* MQL::EXCEPTION::what() const'
&quot;exception&quot;: C:/Programme/compInt/cbx/mingw/include/c++/3.2/exception overriding ` in Zeile 57
virtual const char* std::exception::what() const throw ()'
 MinGW GNU C++ Compiler beendet mit Fehler-Code: 1
Erzeugen wegen Fehler abgebrochen
</code></pre>
<p>Der Code dazu:<br />
mql.hpp</p>
<pre><code class="language-cpp">class MQL
{
public:
#include &quot;mqlException.hpp&quot;
...
};
</code></pre>
<p>mqlException.hpp</p>
<pre><code class="language-cpp">#ifndef GUARD_MQL_EXCEPTION
#define GUARD_MQL_EXCEPTION

#include &lt;stdexcept&gt;

class EXCEPTION : public std::exception
{
public:
	EXCEPTION(const STRING &amp; What = &quot;&quot;);
	[virtual] ~EXCEPTION();   // egal, ob mit oder ohne virtual

	[virtual] const char * what()const; //siehe Destruktor

private:
	STRING m_what;
};
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/853985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/853985</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Wed, 17 Aug 2005 09:40:23 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 10:01:02 GMT]]></title><description><![CDATA[<p>Der Compiler sagt es dir doch bereits, dir fehlt throw() hinter der Funktion:</p>
<pre><code class="language-cpp">virtual const char* what() const throw() {
   //irgendwas
}
</code></pre>
<p>entsprechend auch beim CTor und DTor.</p>
<p>mfg<br />
v R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/854035</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854035</guid><dc:creator><![CDATA[virtuell Realisticer]]></dc:creator><pubDate>Wed, 17 Aug 2005 10:01:02 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 10:08:20 GMT]]></title><description><![CDATA[<p>So sieht std::exception vom Borland C++ Compiler aus:</p>
<pre><code class="language-cpp">class _STLP_CLASS_DECLSPEC __Named_exception : public _STLP_EXCEPTION_BASE {
public:
  __Named_exception(const string&amp; __str) 
# ifdef _STLP_OWN_IOSTREAMS
    ;
  const char* what() const _STLP_NOTHROW_INHERENTLY;
  ~__Named_exception() _STLP_NOTHROW_INHERENTLY;
# else
  {
    strncpy(_M_name, __get_c_string(__str), _S_bufsize);
    _M_name[_S_bufsize - 1] = '\0';
  }
  const char* what() const _STLP_NOTHROW_INHERENTLY { return _M_name; }
# endif

private:
  enum { _S_bufsize = 256 };
  char _M_name[_S_bufsize];
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/854041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854041</guid><dc:creator><![CDATA[denker]]></dc:creator><pubDate>Wed, 17 Aug 2005 10:08:20 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 10:12:36 GMT]]></title><description><![CDATA[<p>Ja, GCC und mein VC++ haben verschiedene STD-Lib-Implementierungen. Bei mir war kein throw. Mußt du dann natürlich bei dir anpassen.</p>
<p>Ich find übrigens deinen Code mit den Eckigen Klammern um virtual herum und wie du includierst seeeeeeehr merkwürdig. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/854046</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854046</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Wed, 17 Aug 2005 10:12:36 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 10:44:57 GMT]]></title><description><![CDATA[<p>virtuell Realisticer schrieb:</p>
<blockquote>
<p>Der Compiler sagt es dir doch bereits, dir fehlt throw() hinter der Funktion:</p>
<pre><code class="language-cpp">virtual const char* what() const throw() {
   //irgendwas
}
</code></pre>
<p>entsprechend auch beim CTor und DTor.</p>
<p>mfg<br />
v R</p>
</blockquote>
<p>hm,<br />
sowas seh ich grade zum allerersten mal.<br />
Hab zwar keinen Plan, für was das &quot;throw()&quot; gut ist/sein soll, aber funktionieren tuts.</p>
<p>Artchi schrieb:</p>
<blockquote>
<p>Ich find übrigens deinen Code mit den Eckigen Klammern um virtual herum und wie du includierst seeeeeeehr merkwürdig. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
</blockquote>
<p>eckiges virtual<br />
Das sollte andeuten, dass der Fehler sowohl mit &quot;virtual&quot; auftaucht,<br />
also auch ohne.</p>
<p>Includes:<br />
Hab hier mehrere Klassen ineinander geschachtelt.<br />
Wird dann relativ unübersichtlich, drum hab ich's in mehrere<br />
Dateien zerlegt</p>
<p>Dann noch ein herzlichen Dankeschön an alle für die Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/854076</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854076</guid><dc:creator><![CDATA[anonymus]]></dc:creator><pubDate>Wed, 17 Aug 2005 10:44:57 GMT</pubDate></item><item><title><![CDATA[Reply to Datengröße für std::exception ändern on Wed, 17 Aug 2005 14:49:36 GMT]]></title><description><![CDATA[<p>anonymus schrieb:</p>
<blockquote>
<p>Hab zwar keinen Plan, für was das &quot;throw()&quot; gut ist/sein soll, aber funktionieren tuts.</p>
</blockquote>
<p>throw () bedeutet, dass diese Funktion keine Exceptions wirft/werfen darf und gehört AFAIK zur Signatur.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/854297</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/854297</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Wed, 17 Aug 2005 14:49:36 GMT</pubDate></item></channel></rss>