scripts/potassium: raise on empty, refactor