try to catch bug in leastsq where linalg errors are not caught