{"action":"created","issue":{"url":"https://api.github.com/repos/ishkawa/APIKit/issues/177","repository_url":"https://api.github.com/repos/ishkawa/APIKit","labels_url":"https://api.github.com/repos/ishkawa/APIKit/issues/177/labels{/name}","comments_url":"https://api.github.com/repos/ishkawa/APIKit/issues/177/comments","events_url":"https://api.github.com/repos/ishkawa/APIKit/issues/177/events","html_url":"https://github.com/ishkawa/APIKit/issues/177","id":157878773,"number":177,"title":"UnexpectedURLRequest seems orphaned in APIKit 2","user":{"login":"takasek","id":1290052,"avatar_url":"https://avatars.githubusercontent.com/u/1290052?v=3","gravatar_id":"","url":"https://api.github.com/users/takasek","html_url":"https://github.com/takasek","followers_url":"https://api.github.com/users/takasek/followers","following_url":"https://api.github.com/users/takasek/following{/other_user}","gists_url":"https://api.github.com/users/takasek/gists{/gist_id}","starred_url":"https://api.github.com/users/takasek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/takasek/subscriptions","organizations_url":"https://api.github.com/users/takasek/orgs","repos_url":"https://api.github.com/users/takasek/repos","events_url":"https://api.github.com/users/takasek/events{/privacy}","received_events_url":"https://api.github.com/users/takasek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-06-01T10:57:29Z","updated_at":"2016-06-21T19:33:19Z","closed_at":null,"body":"See the search result:\r\nhttps://github.com/ishkawa/APIKit/search?utf8=%E2%9C%93&q=UnexpectedURLRequest"},"comment":{"url":"https://api.github.com/repos/ishkawa/APIKit/issues/comments/227547096","html_url":"https://github.com/ishkawa/APIKit/issues/177#issuecomment-227547096","issue_url":"https://api.github.com/repos/ishkawa/APIKit/issues/177","id":227547096,"user":{"login":"ishkawa","id":966856,"avatar_url":"https://avatars.githubusercontent.com/u/966856?v=3","gravatar_id":"","url":"https://api.github.com/users/ishkawa","html_url":"https://github.com/ishkawa","followers_url":"https://api.github.com/users/ishkawa/followers","following_url":"https://api.github.com/users/ishkawa/following{/other_user}","gists_url":"https://api.github.com/users/ishkawa/gists{/gist_id}","starred_url":"https://api.github.com/users/ishkawa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ishkawa/subscriptions","organizations_url":"https://api.github.com/users/ishkawa/orgs","repos_url":"https://api.github.com/users/ishkawa/repos","events_url":"https://api.github.com/users/ishkawa/events{/privacy}","received_events_url":"https://api.github.com/users/ishkawa/received_events","type":"User","site_admin":false},"created_at":"2016-06-21T19:33:19Z","updated_at":"2016-06-21T19:33:19Z","body":"I think the second one is better.\r\n\r\nGenerally, several kind of errors might happen while getting web API response. It is impossible to enumerate possible errors exhaustively because there're [custom errors](https://github.com/ishkawa/APIKit/blob/master/Documentation/DefiningRequestProtocolForWebService.md#throwing-custom-errors-web-api-returns), and that is the reason why associated values of  `SessionTaskType` is *untyped*.\r\n\r\nFrom the viewpoint of call-site, we can get **where** the error occurred by the case of `SessionTaskError`, but can't get the type of the associated error. We have to cast the error to *known* error type to get **what** the error is. Here's an example:\r\n\r\n```swift\r\nlet request = GitHubAPI.SearchRepositoriesRequest(query: \"APIKit\")\r\n\r\nSession.sendRequest(request) { result in\r\n    switch result {\r\n    case .Success(let response):\r\n        print(\"response: \", response)\r\n\r\n    case .Failure(let error):\r\n        switch error {\r\n        case .ResponseError(let gitHubError as GitHubError):\r\n            print(\"GitHub API Error: \\(gitHubError.message)\")\r\n\r\n        default:\r\n            print(\"Unknown Error: \\(error)\")\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThis is exactly the same way to `do-try-catch`, which is untyped error handling model. We can specialize error handling for known error types, but handling unknown errors is unavoidable. In other words, all specializations for known errors are optional, but handling unknown errors is required. Thus, specializations for predefine errors such as `RequestError` and `ResponseError` are also optional."}}
{"actor":{"display_login":"ishkawa"}}