Sol.retcode != :Success not working inside turing model

I’m using sol.retcode != :Success to check my model solution but it throws this error.

nested task error: type TrackedArray has no field retcode

Can someone tell me what can be other way to use sol.retcode ?

Repost. See the documentation:

The recommended form is SciMLBase.successful_retcode(sol.retcode) since that covers more than just ReturnCode.Success.