{"action":"closed","issue":{"url":"https://api.github.com/repos/Arcbot-Org/Arcbot/issues/26","labels_url":"https://api.github.com/repos/Arcbot-Org/Arcbot/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/Arcbot-Org/Arcbot/issues/26/comments","events_url":"https://api.github.com/repos/Arcbot-Org/Arcbot/issues/26/events","html_url":"https://github.com/Arcbot-Org/Arcbot/issues/26","id":110077144,"number":26,"title":"[connector.Discord] API Request exception should be handled gracefully.","user":{"login":"ZetaHunter","id":1717852,"avatar_url":"https://avatars.githubusercontent.com/u/1717852?v=3","gravatar_id":"","url":"https://api.github.com/users/ZetaHunter","html_url":"https://github.com/ZetaHunter","followers_url":"https://api.github.com/users/ZetaHunter/followers","following_url":"https://api.github.com/users/ZetaHunter/following{/other_user}","gists_url":"https://api.github.com/users/ZetaHunter/gists{/gist_id}","starred_url":"https://api.github.com/users/ZetaHunter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZetaHunter/subscriptions","organizations_url":"https://api.github.com/users/ZetaHunter/orgs","repos_url":"https://api.github.com/users/ZetaHunter/repos","events_url":"https://api.github.com/users/ZetaHunter/events{/privacy}","received_events_url":"https://api.github.com/users/ZetaHunter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Arcbot-Org/Arcbot/labels/Bug","name":"Bug","color":"fbca04"},{"url":"https://api.github.com/repos/Arcbot-Org/Arcbot/labels/Connector","name":"Connector","color":"eb6420"},{"url":"https://api.github.com/repos/Arcbot-Org/Arcbot/labels/Refactor","name":"Refactor","color":"0052cc"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-06T18:59:25Z","updated_at":"2016-01-13T15:44:53Z","closed_at":"2016-01-13T15:44:53Z","body":"Some better solution should be done in place of existing code:\r\n```raise Exception(\"API responded with HTTP code  \" + str(response.status_code))```\r\nRight now the bot doesn't handle the exception at any of the layers and ends up killing the thread responsible for handling messages.\r\n\r\nHere's a traceback from an exception I got earlier on my bot:\r\n```\r\nException in thread WorkerThread1:\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python2.7/threading.py\", line 810, in __bootstrap_inner\r\n    self.run()\r\n  File \"/root/arcbot/core/ThreadPool.py\", line 151, in run\r\n    callable(*args, **kwargs)\r\n  File \"connectors/Discord.py\", line 161, in handleMessage\r\n    self.core.command.check(message)\r\n  File \"/root/arcbot/core/Command.py\", line 57, in check\r\n    command.invoke(message)\r\n  File \"/root/arcbot/core/Command.py\", line 37, in invoke\r\n    self.callback(message)\r\n  File \"/root/arcbot/core/Decorators.py\", line 5, in wrapper\r\n    return callback(self, msg)\r\n  File \"plugins/Gaming.py\", line 113, in dice\r\n    self.reply(msg, \"{} ({})\".format(total, \", \".join(rolls)))\r\n  File \"/root/arcbot/core/Plugin.py\", line 69, in reply\r\n    self.core.connection.reply(envelope, message)\r\n  File \"connectors/Discord.py\", line 129, in reply\r\n    self.api.channels.send(self.token, envelope.channel, \"<@{}> {}\".format(envelope.sender, message), mentions=[envelope.sender])\r\n  File \"connectors/Discord.py\", line 333, in send\r\n    return self.request(\"POST\", \"channels/\" + channelID + \"/messages\", postData={\"content\": content, \"mentions\":mentions}, token=token)\r\n  File \"connectors/Discord.py\", line 295, in request\r\n    raise Exception(\"API responded with HTTP code  \" + str(response.status_code) )\r\nException: API responded with HTTP code  409\r\n```"}}