<｜begin▁of▁sentence｜>### Instruction:
In the design of a logistical network for a new product line, where the pathways between distribution points are mapped out digitally using NetworkX, how might we incorporate a failsafe mechanism within our software that ensures each transportation route (edge) between facilities (nodes) holds only valid, positive distance values (weights)? Could we create a safeguard that, when a route with an impractical negative distance is inputted, an informative error message is triggered, thereby maintaining the integrity of our distribution model? Let's imagine this verification process as a quality check label, giving our route map the seal of approval for operational soundness before it goes live.
### Response:
import networkx as nx
from graspologic.preconditions import check_argument

# Function to add an edge with a weight check

# Create a sample graph
G = nx.Graph()

# Function to add an edge with non-negative weight

def add_edge_with_weight_check(graph, node1, node2, weight):
    check_argument(weight >= 0, 'Weight must be non-negative')
    graph.add_edge(node1, node2, weight=weight)

# Example usage
try:
    add_edge_with_weight_check(G, 'A', 'B', -1)
except ValueError as e:
    print(e)
<|EOT|>
