{"action":"opened","issue":{"url":"https://api.github.com/repos/dart-lang/sdk/issues/28860","repository_url":"https://api.github.com/repos/dart-lang/sdk","labels_url":"https://api.github.com/repos/dart-lang/sdk/issues/28860/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/sdk/issues/28860/comments","events_url":"https://api.github.com/repos/dart-lang/sdk/issues/28860/events","html_url":"https://github.com/dart-lang/sdk/issues/28860","id":209521302,"number":28860,"title":"Expose `ErrorCodes` constants (errno)","user":{"login":"tvolkert","id":15253456,"avatar_url":"https://avatars.githubusercontent.com/u/15253456?v=3","gravatar_id":"","url":"https://api.github.com/users/tvolkert","html_url":"https://github.com/tvolkert","followers_url":"https://api.github.com/users/tvolkert/followers","following_url":"https://api.github.com/users/tvolkert/following{/other_user}","gists_url":"https://api.github.com/users/tvolkert/gists{/gist_id}","starred_url":"https://api.github.com/users/tvolkert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tvolkert/subscriptions","organizations_url":"https://api.github.com/users/tvolkert/orgs","repos_url":"https://api.github.com/users/tvolkert/repos","events_url":"https://api.github.com/users/tvolkert/events{/privacy}","received_events_url":"https://api.github.com/users/tvolkert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-22T17:16:51Z","updated_at":"2017-02-22T17:16:51Z","closed_at":null,"body":"**Problem Statement**\r\n\r\nThere are times in code when you catch an IOException and want to perform conditional logic based on the `osError.errorCode` within the exception.  However, for any given semantic error code (e.g. `EISDIR`), its value may differ on various platforms.  Complicating the problem is that the different platforms have disjoint sets of semantic errno values.\r\n\r\n**Proposed Solution**\r\n\r\nIf `dart:io` exposed the set of semantic errno values that is common to all platforms, it would solve the 90% use case.  I propose we create an `ErrorCodes` class with `static const int` values for this set of errno values.\r\n\r\nLooking at the errno values from [Linux](https://gist.github.com/tvolkert/179c1c4b842eef74064e92c1e7aaa15a), [Mac OS](https://gist.github.com/tvolkert/a5da130dacd8f728021dce0377091ad5), and [Windows](https://gist.github.com/tvolkert/b91fd4a5c2aa360e20775f5a39a550a7), it looks like the common set would yield the following: https://gist.github.com/tvolkert/e59f531df15ee54edb71c9d2fba6fe71\r\n\r\n**Alternatives Considered**\r\n\r\n  - We could provide these values as an enum, but we want developers to be able to compare the `IOException.osError.errorCode` int value against these values, so an enum doesn't fit the use case as well as static constants.\r\n  - We could provide all errno values for all platforms (rather than just exposing the common set and abstracting away the platform), but that seems gratuitous and not tailored towards solving a real problem.\r\n  - We could do nothing and let individual libraries worry about this, but given that we already expose the `OSError` and its `errorCode`, it seems like we should provide something like this in `dart:io` itself."}}
{"actor":{"display_login":"tvolkert"}}