{"action":"closed","issue":{"url":"https://api.github.com/repos/restify/errors/issues/30","repository_url":"https://api.github.com/repos/restify/errors","labels_url":"https://api.github.com/repos/restify/errors/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/restify/errors/issues/30/comments","events_url":"https://api.github.com/repos/restify/errors/issues/30/events","html_url":"https://github.com/restify/errors/issues/30","id":146672619,"number":30,"title":"toString doesn not print caused by: ...","user":{"login":"jonathan-rodan","id":1568357,"avatar_url":"https://avatars.githubusercontent.com/u/1568357?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathan-rodan","html_url":"https://github.com/jonathan-rodan","followers_url":"https://api.github.com/users/jonathan-rodan/followers","following_url":"https://api.github.com/users/jonathan-rodan/following{/other_user}","gists_url":"https://api.github.com/users/jonathan-rodan/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathan-rodan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathan-rodan/subscriptions","organizations_url":"https://api.github.com/users/jonathan-rodan/orgs","repos_url":"https://api.github.com/users/jonathan-rodan/repos","events_url":"https://api.github.com/users/jonathan-rodan/events{/privacy}","received_events_url":"https://api.github.com/users/jonathan-rodan/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/restify/errors/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/restify/errors/labels/fixed%20but%20not%20yet%20released","name":"fixed but not yet released","color":"0e8a16"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-07T16:14:24Z","updated_at":"2016-05-09T18:10:03Z","closed_at":"2016-05-09T18:10:03Z","body":"I was trying to create an error handler and noticed that toString wasn't working properly (or at least not as documented).\r\n\r\n```\r\nconst internalError = new errors.NotFoundError('NotFoundError message');\r\nconst outerError = new errors.UnauthorizedError(internalError, 'UnauthorizedError message');\r\n\r\nconsole.log(outerError.toString());\r\n// UnauthorizedError: UnauthorizedError message\r\n\r\nconsole.log(outerError.message);\r\n// UnauthorizedError message\r\n\r\nconsole.log(outerError);\r\n/*\r\n{ [UnauthorizedError: UnauthorizedError message]\r\n  message: 'UnauthorizedError message',\r\n  we_cause: \r\n   { [NotFoundError: NotFoundError message]\r\n     message: 'NotFoundError message',\r\n     body: { code: 'NotFound', message: 'NotFoundError message' },\r\n     context: null },\r\n  body: { code: 'Unauthorized', message: 'UnauthorizedError message' },\r\n  context: null }\r\n*/\r\n```\r\n\r\nThe documentation describes\r\n\r\n<img width=\"914\" alt=\"screen shot 2016-04-07 at 11 21 51 am\" src=\"https://cloud.githubusercontent.com/assets/1568357/14356479/10b3b382-fcb3-11e5-83a3-a48e1cdea4c4.png\">\r\n\r\n\r\nI can create a pull request, but I don't want to do it without knowing what to change the toString or the documentation.\r\n\r\nIf you prefer to update the docs, I'd like to create a `messageWithCause()` function that keeps the `caused by`."}}