Improve dealing with exceptions

re #6175
Merge branch 'feature/6175_script_repo' into develop

re #6175
Enable ScriptRepositoryTest

re #6175