Fixed error handling in str2int and hex2int