{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/285","repository_url":"https://api.github.com/repos/rust-lang-nursery/failure","labels_url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/285/comments","events_url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/285/events","html_url":"https://github.com/rust-lang-nursery/failure/issues/285","id":392708938,"node_id":"MDU6SXNzdWUzOTI3MDg5Mzg=","number":285,"title":"Match a concrete type issue","user":{"login":"alexandrvoronsky","id":40764944,"node_id":"MDQ6VXNlcjQwNzY0OTQ0","avatar_url":"https://avatars3.githubusercontent.com/u/40764944?v=4","gravatar_id":"","url":"https://api.github.com/users/alexandrvoronsky","html_url":"https://github.com/alexandrvoronsky","followers_url":"https://api.github.com/users/alexandrvoronsky/followers","following_url":"https://api.github.com/users/alexandrvoronsky/following{/other_user}","gists_url":"https://api.github.com/users/alexandrvoronsky/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandrvoronsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandrvoronsky/subscriptions","organizations_url":"https://api.github.com/users/alexandrvoronsky/orgs","repos_url":"https://api.github.com/users/alexandrvoronsky/repos","events_url":"https://api.github.com/users/alexandrvoronsky/events{/privacy}","received_events_url":"https://api.github.com/users/alexandrvoronsky/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-12-19T17:39:45Z","updated_at":"2018-12-20T09:02:16Z","closed_at":"2018-12-20T09:02:16Z","author_association":"NONE","body":"Hello guys! \r\n\r\nI am trying to use failure, but have some issues (except my rustasian newbie skills). It would be great if you will help me to understand how to resolve them.\r\nSo, I have defined my error using enum:\r\n```\r\n#[derive(Debug, Fail)]\r\npub enum MyErrorType {\r\n    #[fail(display = \"Thing is not found\")]\r\n    NotFound,\r\n    #[fail(display = \"Unknown error\")]\r\n    Unknown,\r\n}\r\n```\r\nThe next thing what I am going to do is to throw an Error:\r\n```\r\nfn throw() -> Result<(), Error> {\r\n    Err(MyErrorType::NotFound.into())\r\n}\r\n```\r\nAnd the problem that is not clear to me at all - how to catch the actual type:\r\n```\r\nlet res = match throw() {\r\n                Ok(()) => \"ok\",\r\n                Err(err) => {\r\n                    match err {\r\n                        MyErrorType::NotFound => \"1\",\r\n                        MyErrorType::Unknown => \"2\"\r\n                    }\r\n                }\r\n            }\r\n```\r\nHow to properly deal with it?\r\n\r\nBTW if to use separate structs instead of enum it will be working. I mean smth like this:\r\n```\r\n#[derive(Debug, Fail)]\r\n#[fail(display = \"Error Unknown\")]\r\npub struct MyErrorTypeUnknown\r\n\r\n#[derive(Debug, Fail)]\r\n#[fail(display = \"ErrorNotFound\")]\r\npub struct MyErrorTypeNotFound\r\n\r\nlet res = match throw() {\r\n                Ok(()) => \"ok\",\r\n                Err(err) => {\r\n                    match err {\r\n                        MyErrorTypeNotFound => \"1\",\r\n                        MyErrorTypeUnknown=> \"2\"\r\n                    }\r\n                }\r\n            }\r\n```\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/comments/448923857","html_url":"https://github.com/rust-lang-nursery/failure/issues/285#issuecomment-448923857","issue_url":"https://api.github.com/repos/rust-lang-nursery/failure/issues/285","id":448923857,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0ODkyMzg1Nw==","user":{"login":"alexandrvoronsky","id":40764944,"node_id":"MDQ6VXNlcjQwNzY0OTQ0","avatar_url":"https://avatars3.githubusercontent.com/u/40764944?v=4","gravatar_id":"","url":"https://api.github.com/users/alexandrvoronsky","html_url":"https://github.com/alexandrvoronsky","followers_url":"https://api.github.com/users/alexandrvoronsky/followers","following_url":"https://api.github.com/users/alexandrvoronsky/following{/other_user}","gists_url":"https://api.github.com/users/alexandrvoronsky/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandrvoronsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandrvoronsky/subscriptions","organizations_url":"https://api.github.com/users/alexandrvoronsky/orgs","repos_url":"https://api.github.com/users/alexandrvoronsky/repos","events_url":"https://api.github.com/users/alexandrvoronsky/events{/privacy}","received_events_url":"https://api.github.com/users/alexandrvoronsky/received_events","type":"User","site_admin":false},"created_at":"2018-12-20T09:02:16Z","updated_at":"2018-12-20T09:02:16Z","author_association":"NONE","body":"Tried to build and it works this way. \r\nBut the last mystery thing I don't why nor RLS nor Intellij won't highlight it and index as a function. It could be resolved by myself if I knew that syntax highlighter is not working properly. =)\r\n\r\nThanks you very much!"}}
{"actor":{"display_login":"alexandrvoronsky"}}