{"action":"closed","issue":{"url":"https://api.github.com/repos/vdemedes/mongorito/issues/42","labels_url":"https://api.github.com/repos/vdemedes/mongorito/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/vdemedes/mongorito/issues/42/comments","events_url":"https://api.github.com/repos/vdemedes/mongorito/issues/42/events","html_url":"https://github.com/vdemedes/mongorito/issues/42","id":81484293,"number":42,"title":"Catching errors","user":{"login":"seemsindie","id":1268576,"avatar_url":"https://avatars.githubusercontent.com/u/1268576?v=3","gravatar_id":"","url":"https://api.github.com/users/seemsindie","html_url":"https://github.com/seemsindie","followers_url":"https://api.github.com/users/seemsindie/followers","following_url":"https://api.github.com/users/seemsindie/following{/other_user}","gists_url":"https://api.github.com/users/seemsindie/gists{/gist_id}","starred_url":"https://api.github.com/users/seemsindie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seemsindie/subscriptions","organizations_url":"https://api.github.com/users/seemsindie/orgs","repos_url":"https://api.github.com/users/seemsindie/repos","events_url":"https://api.github.com/users/seemsindie/events{/privacy}","received_events_url":"https://api.github.com/users/seemsindie/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-27T15:04:31Z","updated_at":"2015-05-31T18:03:38Z","closed_at":"2015-05-31T18:03:38Z","body":"Hello,\r\n\r\nI have the following code:\r\n\r\n    yield User.index('email', { unique: true });\r\n\r\n\r\n    var salt = yield bcrypt.genSalt(10);\r\n\r\n    var user = new User({\r\n      email: this.request.body.email,\r\n      password: yield bcrypt.hash(this.request.body.password, salt),\r\n      salt: salt\r\n    });\r\n\r\n    try {\r\n      yield user.save();\r\n    } catch (err) {\r\n      console.log(\"ERROR:\", e);\r\n      this.body = e;\r\n      return;\r\n    }\r\n\r\nI have the two questions:\r\n\r\nIs there any better place to place index(), i currently have it in the main js file, when the server starts. And i feel it should be in model, but don't know where to put it.\r\n\r\nThe second question is about catching errors, as you can see i have try/catch block. But it doesn't seem to catch any errors, it doesn't logs or puts in the body. I want to ask what i am doing wrong?\r\n\r\nThanks.\r\n"}}