Fixed the way exceptions are thrown.