Modified the networking code to return a Result enum type for better error handling