Catch errors and return initial value depending on type