handling exceptions and logging errors