Fixes issue #501 and improves an error message

I was getting an error from my supervisor config due to having %(process_num)s
in the command field of a program. This is supposed to work, but apparently some
refactoring broke it accidentally. The reason is that we call saneget outside
the for-loop that sets the process_num value, and so the expansion fails.

This also improves the "Format string contains names which cannot be expanded"
error message, so that it displays a list of expansions variables that are
available.