{"action":"closed","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/827","labels_url":"https://api.github.com/repos/nengo/nengo/issues/827/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/827/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/827/events","html_url":"https://github.com/nengo/nengo/issues/827","id":104187120,"number":827,"title":"Adding modules with errors to an SPA network obscures the real error message.","user":{"login":"xchoo","id":1971583,"avatar_url":"https://avatars.githubusercontent.com/u/1971583?v=3","gravatar_id":"","url":"https://api.github.com/users/xchoo","html_url":"https://github.com/xchoo","followers_url":"https://api.github.com/users/xchoo/followers","following_url":"https://api.github.com/users/xchoo/following{/other_user}","gists_url":"https://api.github.com/users/xchoo/gists{/gist_id}","starred_url":"https://api.github.com/users/xchoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xchoo/subscriptions","organizations_url":"https://api.github.com/users/xchoo/orgs","repos_url":"https://api.github.com/users/xchoo/repos","events_url":"https://api.github.com/users/xchoo/events{/privacy}","received_events_url":"https://api.github.com/users/xchoo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nengo/nengo/labels/bug","name":"bug","color":"000000"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-01T04:58:16Z","updated_at":"2015-09-02T13:33:57Z","closed_at":"2015-09-02T13:33:57Z","body":"Exceptions thrown within modules are not passed along to the user. Instead, the user just gets a very unhelpful message:\r\n```\r\nValueError: <ModuleName> was not added as an attribute to of                     the SPA network and won't be detected\r\n```\r\n(Note: the extra spacing is also a bug)\r\n\r\nI think this is what is happening:\r\n1. Module is added to the SPA network (nengo registers the add successfully)\r\n2. ```__setattr__``` function is called\r\n3. exception is thrown (and module is not added to the SPA network\r\n4. ```__exit__``` function is called (because of the exception)\r\n5. Which can't find the recently added network in the modules list\r\n6. ValueError is thrown.\r\n\r\nTest example:\r\n```\r\nclass TestModule(Module):\r\n    def __init__(self, label=\"Test\", seed=None, add_to_container=None):\r\n        super(TestModule, self).__init__(label, seed, add_to_container)\r\n        with self:\r\n            raise Exception(\"EXCEPTION!\")\r\n\r\nwith spa.SPA() as model:\r\n    model.test = TestModule()\r\n\r\nsim = nengo.Simulator(model)\r\n```\r\n\r\nError message:\r\n```\r\nValueError: <TestModule \"Test\"> was not added as an attribute to of                     the SPA network and won't be detected\r\n```"}}