Adding try catch to process_messages