Improve format_idl_param function and add more error checks.