{"action":"closed","issue":{"url":"https://api.github.com/repos/winjs/winjs/issues/1050","labels_url":"https://api.github.com/repos/winjs/winjs/issues/1050/labels{/name}","comments_url":"https://api.github.com/repos/winjs/winjs/issues/1050/comments","events_url":"https://api.github.com/repos/winjs/winjs/issues/1050/events","html_url":"https://github.com/winjs/winjs/issues/1050","id":68523862,"number":1050,"title":"WinJS.Promise.timeout: How to find out if promise canceled by timeout or user?","user":{"login":"pke","id":164625,"avatar_url":"https://avatars.githubusercontent.com/u/164625?v=3","gravatar_id":"","url":"https://api.github.com/users/pke","html_url":"https://github.com/pke","followers_url":"https://api.github.com/users/pke/followers","following_url":"https://api.github.com/users/pke/following{/other_user}","gists_url":"https://api.github.com/users/pke/gists{/gist_id}","starred_url":"https://api.github.com/users/pke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pke/subscriptions","organizations_url":"https://api.github.com/users/pke/orgs","repos_url":"https://api.github.com/users/pke/repos","events_url":"https://api.github.com/users/pke/events{/privacy}","received_events_url":"https://api.github.com/users/pke/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/winjs/winjs/labels/.kind:%20featurerequest","name":".kind: featurerequest","color":"c7def8"}],"state":"closed","locked":false,"assignee":{"login":"jayrenn","id":7266075,"avatar_url":"https://avatars.githubusercontent.com/u/7266075?v=3","gravatar_id":"","url":"https://api.github.com/users/jayrenn","html_url":"https://github.com/jayrenn","followers_url":"https://api.github.com/users/jayrenn/followers","following_url":"https://api.github.com/users/jayrenn/following{/other_user}","gists_url":"https://api.github.com/users/jayrenn/gists{/gist_id}","starred_url":"https://api.github.com/users/jayrenn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jayrenn/subscriptions","organizations_url":"https://api.github.com/users/jayrenn/orgs","repos_url":"https://api.github.com/users/jayrenn/repos","events_url":"https://api.github.com/users/jayrenn/events{/privacy}","received_events_url":"https://api.github.com/users/jayrenn/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/winjs/winjs/milestones/4","html_url":"https://github.com/winjs/winjs/milestones/Feature%20Requests","labels_url":"https://api.github.com/repos/winjs/winjs/milestones/4/labels","id":632081,"number":4,"title":"Feature Requests","description":"Backlog of features that are not yet scheduled to be implemented. \r\n\r\nIn general, as feature requests come up they will either be aligned with already scheduled work or will represent new things the team did not already have plans to do.\r\n\r\nIf they are already in-plan we will move them directly into the milestone in which they are to be implemented or merge the issue with an existing already open issue.\r\n\r\nIf they are are not yet in-plan we will move them to this holding milestone and take them into account when planning future milestones. As discussed in our [roadmap](https://github.com/winjs/winjs/wiki/Roadmap) our milestones are more concrete the closer they are to the present; a feature being in this *Feature Requests* milestone does not mean it will not make it into a currently scheduled milestone, it simply means it is unlikely to be executed upon in the current milestone.","creator":{"login":"spankyj","id":4666791,"avatar_url":"https://avatars.githubusercontent.com/u/4666791?v=3","gravatar_id":"","url":"https://api.github.com/users/spankyj","html_url":"https://github.com/spankyj","followers_url":"https://api.github.com/users/spankyj/followers","following_url":"https://api.github.com/users/spankyj/following{/other_user}","gists_url":"https://api.github.com/users/spankyj/gists{/gist_id}","starred_url":"https://api.github.com/users/spankyj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spankyj/subscriptions","organizations_url":"https://api.github.com/users/spankyj/orgs","repos_url":"https://api.github.com/users/spankyj/repos","events_url":"https://api.github.com/users/spankyj/events{/privacy}","received_events_url":"https://api.github.com/users/spankyj/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":73,"state":"open","created_at":"2014-04-16T17:54:17Z","updated_at":"2015-06-30T20:10:49Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-04-14T23:15:50Z","updated_at":"2015-06-30T20:10:49Z","closed_at":"2015-06-30T20:10:49Z","body":"I have a server request that is wrapped in a timeout promise. `var pendingRequest = WinJS.Promise.timeout(5000, requestAsync)`. The user also has a \"Cancel\" button on the UI to actively cancel the request. However, there is no way to find out that the promise has been cancelled by the user or by the timeout.\r\nIt's too late in the game but the timeout promise should probably cancel itself with a different error than a call to `cancel()` would normally produce, something like \"timeout\". Then we could check in our error handler:\r\n```\r\npendingRequest.then(null, function(error) {\r\n  if (error.name === \"Canceled\") // by user\r\n  if (error.name === \"Timeout\") // by timeout\r\n}); \r\n```\r\n\r\nOr the cancel method would optionally accept an `error` argument to use to set the promise into error state.\r\n\r\nAny idea how to do that with the current state of Promises?"}}