Replace assert method, that would call OnError()