{"action":"created","issue":{"url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/31","labels_url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/31/labels{/name}","comments_url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/31/comments","events_url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/31/events","html_url":"https://github.com/englue/meteor-publish-composite/issues/31","id":55389911,"number":31,"title":"Trigger error callbacks on errors within nested functions","user":{"login":"fongandrew","id":179327,"avatar_url":"https://avatars.githubusercontent.com/u/179327?v=3","gravatar_id":"","url":"https://api.github.com/users/fongandrew","html_url":"https://github.com/fongandrew","followers_url":"https://api.github.com/users/fongandrew/followers","following_url":"https://api.github.com/users/fongandrew/following{/other_user}","gists_url":"https://api.github.com/users/fongandrew/gists{/gist_id}","starred_url":"https://api.github.com/users/fongandrew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fongandrew/subscriptions","organizations_url":"https://api.github.com/users/fongandrew/orgs","repos_url":"https://api.github.com/users/fongandrew/repos","events_url":"https://api.github.com/users/fongandrew/events{/privacy}","received_events_url":"https://api.github.com/users/fongandrew/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-25T00:08:28Z","updated_at":"2015-02-06T22:26:38Z","closed_at":"2015-02-06T00:48:18Z","body":"It is possible to pass an `onError` callback to `Meteor.subscribe` that is fired when there is an error within the publication or the publication explicitly calls `this.error()`.\r\n\r\nThis doesn't appear to work if the error occurs within a nested `find` function (although explicitly calling `this.error()` does still work) -- that is ...\r\n\r\n```javascript\r\nMeteor.publishComposite('mySub', {\r\n  find: function() {\r\n    return Universes.find();\r\n    throw new Meteor.Error(500, \"error\"); // Triggers onError callback\r\n  },\r\n  children: [\r\n    { \r\n      find: function(doc) {\r\n        throw new Meteor.Error(500, \"error\"); // Does not trigger onError callback\r\n      }\r\n    }, {\r\n      find: function(doc) { \r\n        this.error(500); // Triggers onError callback\r\n      }\r\n    }\r\n  ]\r\n});\r\n```\r\n\r\nIt'd be nice if publish-composite had an option to automatically wrap each child find function in a try/catch block and call this.error if any of them fail."},"comment":{"url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/comments/73324457","html_url":"https://github.com/englue/meteor-publish-composite/issues/31#issuecomment-73324457","issue_url":"https://api.github.com/repos/englue/meteor-publish-composite/issues/31","id":73324457,"user":{"login":"reywood","id":1796302,"avatar_url":"https://avatars.githubusercontent.com/u/1796302?v=3","gravatar_id":"","url":"https://api.github.com/users/reywood","html_url":"https://github.com/reywood","followers_url":"https://api.github.com/users/reywood/followers","following_url":"https://api.github.com/users/reywood/following{/other_user}","gists_url":"https://api.github.com/users/reywood/gists{/gist_id}","starred_url":"https://api.github.com/users/reywood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reywood/subscriptions","organizations_url":"https://api.github.com/users/reywood/orgs","repos_url":"https://api.github.com/users/reywood/repos","events_url":"https://api.github.com/users/reywood/events{/privacy}","received_events_url":"https://api.github.com/users/reywood/received_events","type":"User","site_admin":false},"created_at":"2015-02-06T22:26:38Z","updated_at":"2015-02-06T22:26:38Z","body":"Happens to the best of us :)"}}