a new Error containing an ClientError of the given
code. If the custom_msg is NULL, then the error message is the one returned from
error_to_string for the code, otherwise the given
message is used. Returned pointer should be freed with g_error_free.