fix Issue 10326 - Change old `invariant` usage to error

deprecation -> error
Merge pull request #2160 from 9rnsr/fix10326

Issue 10326 - Change old `invariant` usage to error