Major refactor of exception handling

Exception handling based on Boost Exception library was a real mess. This
huge change provides a more appropriate way to handle exceptions. See
issue #21 for further details.

In this implementation, a new header file `format.h` is added, which
provides convenience functions for formatting strings based on Boost
Format.