use exceptions to deal with errors in AutoDiff