Exceptions handling and logging