Refactored error messagese to use PrintMessageDieOnError function