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:

https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes

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