Fix error string conversion to use swtich statement (safer)