Refactor exception handling to use Boost.Exception.