Error handling and logging via exceptions