Constructing time integration with controllable errors for constrained mechanical systems