{"action":"created","issue":{"url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/136","repository_url":"https://api.github.com/repos/googleads/google-api-ads-ruby","labels_url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/136/comments","events_url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/136/events","html_url":"https://github.com/googleads/google-api-ads-ruby/issues/136","id":252577937,"number":136,"title":"Add support for getting index of nested operation in error response","user":{"login":"amrutjadhav","id":9390353,"avatar_url":"https://avatars0.githubusercontent.com/u/9390353?v=4","gravatar_id":"","url":"https://api.github.com/users/amrutjadhav","html_url":"https://github.com/amrutjadhav","followers_url":"https://api.github.com/users/amrutjadhav/followers","following_url":"https://api.github.com/users/amrutjadhav/following{/other_user}","gists_url":"https://api.github.com/users/amrutjadhav/gists{/gist_id}","starred_url":"https://api.github.com/users/amrutjadhav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amrutjadhav/subscriptions","organizations_url":"https://api.github.com/users/amrutjadhav/orgs","repos_url":"https://api.github.com/users/amrutjadhav/repos","events_url":"https://api.github.com/users/amrutjadhav/events{/privacy}","received_events_url":"https://api.github.com/users/amrutjadhav/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-08-24T11:56:31Z","updated_at":"2017-08-26T05:01:59Z","closed_at":null,"body":"Currently, if any operation fails, library allows user to get index of operation which have caused error by using function `AdwordsApi::Utils.operation_index_for_error(error)` which is great. But there is no way to get index of suboperation which caused error.\r\n\r\nFor eg. Cosider following error\r\n```\r\n{\"field_path\"=>\r\n      \"operations[0].operand.extensionSetting.extensions[2].sitelinkFinalUrls\",\r\n     \"field_path_elements\"=>\r\n      [{\"field\"=>\"operations\", \"index\"=>0},\r\n       {\"field\"=>\"operand\"},\r\n       {\"field\"=>\"extensionSetting\"},\r\n       {\"field\"=>\"extensions\", \"index\"=>2},\r\n       {\"field\"=>\"sitelinkFinalUrls\"}],\r\n     \"trigger\"=>\"\",\r\n     \"error_string\"=>\"UrlError.INVALID_URL\",\r\n     \"api_error_type\"=>\"UrlError\",\r\n     \"reason\"=>\"INVALID_URL\",\r\n     \"xsi_type\"=>\"UrlError\"}\r\n```\r\nHere third extension of first operation caused error. In this case, user has to manually parse response and get index of extension.\r\nIt would be great if you add support for getting index of such nested operations also.\r\nRecently I faced same problem. So I created new function to get index of extension sub operation. \r\n```\r\ndef extension_index_for_error(error)\r\n  if(error && error[:field_path] and error[:field_path].kind_of?(String))\r\n    match = error[:field_path].match(/extensions\\[(\\d+)\\]/)\r\n    return match ? match[1].to_i : nil\r\n  end\r\n  return nil\r\nend #end extension_index_for_error\r\n```"},"comment":{"url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/comments/325086928","html_url":"https://github.com/googleads/google-api-ads-ruby/issues/136#issuecomment-325086928","issue_url":"https://api.github.com/repos/googleads/google-api-ads-ruby/issues/136","id":325086928,"user":{"login":"amrutjadhav","id":9390353,"avatar_url":"https://avatars0.githubusercontent.com/u/9390353?v=4","gravatar_id":"","url":"https://api.github.com/users/amrutjadhav","html_url":"https://github.com/amrutjadhav","followers_url":"https://api.github.com/users/amrutjadhav/followers","following_url":"https://api.github.com/users/amrutjadhav/following{/other_user}","gists_url":"https://api.github.com/users/amrutjadhav/gists{/gist_id}","starred_url":"https://api.github.com/users/amrutjadhav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amrutjadhav/subscriptions","organizations_url":"https://api.github.com/users/amrutjadhav/orgs","repos_url":"https://api.github.com/users/amrutjadhav/repos","events_url":"https://api.github.com/users/amrutjadhav/events{/privacy}","received_events_url":"https://api.github.com/users/amrutjadhav/received_events","type":"User","site_admin":false},"created_at":"2017-08-26T05:01:59Z","updated_at":"2017-08-26T05:01:59Z","body":"Yes, I can. But as `field_path` elements contains index of operations also, we can get operation index from `field_path` hash directly. Still library provide `AdwordsApi::Utils.operation_index_for_error(error)` function to access it. So I thought there should be also a function to get index of nested operation also."}}
{"actor":{"display_login":"amrutjadhav"}}