{"action":"created","issue":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/3067","labels_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3067/labels{/name}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3067/comments","events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3067/events","html_url":"https://github.com/elixir-lang/elixir/pull/3067","id":57306641,"number":3067,"title":"Add an `:optional` option to `IEx.Helpers.import_file/1`","user":{"login":"whatyouhide","id":3890250,"avatar_url":"https://avatars.githubusercontent.com/u/3890250?v=3","gravatar_id":"","url":"https://api.github.com/users/whatyouhide","html_url":"https://github.com/whatyouhide","followers_url":"https://api.github.com/users/whatyouhide/followers","following_url":"https://api.github.com/users/whatyouhide/following{/other_user}","gists_url":"https://api.github.com/users/whatyouhide/gists{/gist_id}","starred_url":"https://api.github.com/users/whatyouhide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whatyouhide/subscriptions","organizations_url":"https://api.github.com/users/whatyouhide/orgs","repos_url":"https://api.github.com/users/whatyouhide/repos","events_url":"https://api.github.com/users/whatyouhide/events{/privacy}","received_events_url":"https://api.github.com/users/whatyouhide/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-11T11:53:35Z","updated_at":"2015-02-11T13:28:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elixir-lang/elixir/pulls/3067","html_url":"https://github.com/elixir-lang/elixir/pull/3067","diff_url":"https://github.com/elixir-lang/elixir/pull/3067.diff","patch_url":"https://github.com/elixir-lang/elixir/pull/3067.patch"},"body":"As discused in #3066, this PR adds an `:optional` option to the `IEx.Helpers.import_file/1` macro so that the macro can be told not to fail if the given file is missing.\r\n\r\nI'm not 100% sure the code I wrote is the cleanest way to accomplish this; the code smell seems to be manually raising a `File.Error` with all the right exception metadata (previously this was done by reading the file contents with `File.read!/1` instead of `File.read/1`). Another approach I tackled has been to use `File.read!/1` but wrap it in a `try`/`rescue` clause matching on a `File.Error`, only reraising with a `false` `:optional` option. Let me know what you think!\r\n\r\n**PS** This should close #3066."},"comment":{"url":"https://api.github.com/repos/elixir-lang/elixir/issues/comments/73880398","html_url":"https://github.com/elixir-lang/elixir/pull/3067#issuecomment-73880398","issue_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3067","id":73880398,"user":{"login":"whatyouhide","id":3890250,"avatar_url":"https://avatars.githubusercontent.com/u/3890250?v=3","gravatar_id":"","url":"https://api.github.com/users/whatyouhide","html_url":"https://github.com/whatyouhide","followers_url":"https://api.github.com/users/whatyouhide/followers","following_url":"https://api.github.com/users/whatyouhide/following{/other_user}","gists_url":"https://api.github.com/users/whatyouhide/gists{/gist_id}","starred_url":"https://api.github.com/users/whatyouhide/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whatyouhide/subscriptions","organizations_url":"https://api.github.com/users/whatyouhide/orgs","repos_url":"https://api.github.com/users/whatyouhide/repos","events_url":"https://api.github.com/users/whatyouhide/events{/privacy}","received_events_url":"https://api.github.com/users/whatyouhide/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T13:28:15Z","updated_at":"2015-02-11T13:28:15Z","body":"@josevalim Sorry, \"quoted\" it wrong :) there you go!"}}