Improve the cast from exception to unicode.

The error handler for HTTP-related errors was recently improved to decode
utf-8, but some exceptions are better at acting like strings than others. This
change adds an explicit cast.

Testing done: Ran unit tests.

Fixes bugs 3419, 3420.