Improve error handling in case of assert error