--===============0690471338==
Content-Type: multipart/signed;
boundary="nextPart1663142.a8MOcCr3ef";
protocol="application/pgp-signature";
micalg=pgp-sha1
Content-Transfer-Encoding: 7bit

--nextPart1663142.a8MOcCr3ef
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On Monday 05 December 2005 21:04, David Johnson wrote:
> On Monday 05 December 2005 05:55 am, R.F. Pels wrote:
> > Not to mention the fact I had to
> > use my airsickness bag when I saw the 'use-return-codes' solution.

>
> Here's the style of code that causes me to reach for that little baggie:


Well you've successfully emulated error return codes with exceptions. :P

Of course nothing is perfect (and especially so with C++ . But exception=
s=20
can be useful, especially when used as intended. It is especially useful f=
or=20
situations where any error in a long function block is pretty much guarante=
ed=20
to be a fatal logic error (i.e., failure, but no cleanup necessary).

And even if cleanup is necessary, if you properly control the lifetime of t=
he=20
objects in question using classes, then even that isn't an issue.

i.e.

bool doStuff(const HTTPData &html)
{
try {
// Might throw if this wasn't HTML.
HTMLDocument doc =3D html->htmlDocument();

// Can throw if no such node.
Node body =3D doc.findFirstElement("body");

// Can throw if no such attribute.
Attribute bgColor =3D body.getAttribute("bgColor");

// This probably couldn't throw in a sane impl but you
// get the point.
QString clrString =3D bgColor.asString();
}
catch (DOMException e) {
kdError(DEBUG_AREA) << "Error with request: " << e.error() << endl;

// Failed, return error.
return false;
}

return true;
}

Notice how I even managed to use both techniques. However, if I hadn't use=
d=20
exception where I did, I would have had to manually check every return code=
,=20
otherwise I would risk having the application crash on malformed network da=
ta=20
(or worse...). In this case, exceptions were a boon and not a bane.

But, it is much easier just to ignore return codes, so I shall expect to he=
ar=20
whining about exceptions until the very day I die.

Regards,
- Michael Pyne

--nextPart1663142.a8MOcCr3ef
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQBDlPeGqjQYp5Omm0oRApNPAKCkHo5HBrBiCEPHzIEv0m LsRkA8+gCfRg96
VXVbNiLK3u/Zc5q6KUHjiik=
=XHJz
-----END PGP SIGNATURE-----

--nextPart1663142.a8MOcCr3ef--

--===============0690471338==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


--===============0690471338==--