Jason R. Coombs avatar Jason R. Coombs committed 623fa09

Use new explicit exceptions to trap exceptions. Also trap unknown exceptions.

Comments (0)

Files changed (2)

 import itertools
 
 import irc.bot
+import irc.client
 import pkg_resources
 
 import pmxbot.itertools
 			log = False
 		try:
 			func(channel, s)
-		except ValueError as exc:
+		except irc.client.MessageTooLong:
 			# some messages will fail because they're too long
-			if u'512 bytes' in unicode(exc):
-				globals()['log'].warning("Long message could not be "
-					"transmitted: %s", s)
-				return
-			if u'Carriage returns not allowed' in unicode(exc):
-				globals()['log'].warning("Message contains carriage returns, "
-					"which aren't allowed in IRC messages: %r", s)
-				return
-			raise
+			globals()['log'].warning("Long message could not be "
+				"transmitted: %s", s)
+			return
+		except irc.client.InvalidCharacters:
+			globals()['log'].warning("Message contains carriage returns, "
+				"which aren't allowed in IRC messages: %r", s)
+			return
+		except Exception:
+			globals()['log'].exception("Unhandled exception transmitting "
+				"message: %r", s)
+			return
 		if (
 				channel in self._channels
 				and channel in pmxbot.config.log_channels
 		],
 	),
 	install_requires=[
-		"irc>=3.3,<5.0dev",
+		"irc>=3.6,<5.0dev",
 		"popquotes>=1.3",
 		"excuses>=1.1.2",
 		"pyyaml",
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.