NbKnots of edge


I'm getting this error, when executing the code below: terminate called after throwing an instance of 'Standard_NoSuchObject'


    gp_Pnt aPnt1(0, 0, 0);
    gp_Pnt aPnt2(1, 0, 0);
    TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aPnt1, aPnt2);
    BRepAdaptor_Curve b(aEdge1);
    auto n = b.NbKnots();

Am i using the function wrong? I want to use this information to check if the edge is a straight line.