Add primitive error handling and logging