trust your technolust

Friday, March 25, 2005

Exceptional C++

In other fluffy, inefficient lanuages like Java, exceptions are all derived from one base. This has the unfortunate side effect of catching all exceptions whenever you catch (Exception e). Fortunately, the C++ code I am working with does no such clustering - if you would like to catch FileFormatException, then you best catch it or catch (...). Otherwise, it is left to some other code to deal with this stray. Useful? Maybe. Infuriating? Certainly. My impression so far is that every exception should derive from a common base (probably std::exception), so that you can always tell the user something. If you must instead take the tragic path of catching (...), then your error message will probably look something like this:

"An exception has ocurred. Sorry."

Because you don't have any idea what happened - only that something happened. Let me set you on the right path: knowing that something happened isn't useful to anyone - including yourself. Check your parents, kids - std::exception is your friend.

Thursday, March 10, 2005

Mono SVN - building on the Mac

Building Mono from SVN on the Mac can be pretty aggrevating. There aren't a lot of people doing it, and I suspect that when it finally does work, most people don't know what they did differently. To further complicate things, there is a "Framework" .pkg of Mono that most people have installed. It doesn't seem like a good idea to have a SVN build in /usr/local and a package build in /Library/Frameworks. Here are some commands that should build Mono from SVN properly (or close to it):

fink scanpackages; fink index; fink selfupdate; fink update-all
cd mono-checkout-directory
ACLOCAL_FLAGS="-I /sw/share/aclocal" ./autogen.sh --prefix=/Library/Frameworks/Mono.framework --with-preview=yes
sudo make install


This assumes that you have mono checked out from SVN. If not, you should check out http://www.mono-project.com/Mono:OSX. There is a script (which will need editing) available via:

svn co svn://svn.myrealbox.com/source/trunk/mono/web
./mono-build-mac-fw-release.sh


I have updated mono-build-mac-fw-release.sh - the patch can be applied with the following command:

cd mono-svn/mono/web
patch -p0 < mono-build-mac-fw-release_sh.patch