~tribaal/txaws/xss-hardening

« back to all changes in this revision

Viewing changes to txaws/server/exception.py

  • Committer: Alberto Donato
  • Date: 2011-12-01 14:19:12 UTC
  • mto: This revision was merged to the branch mainline in revision 104.
  • Revision ID: alberto.donato@canonical.com-20111201141912-54pen2eyv2o1q23a
Return paramters values as utf8 in errors, if possible.
Convert APIError message to string to avoid problems with twisted logger.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
            if self.code is not None or self.message is not None:
24
24
                raise RuntimeError("If the full response payload is passed, "
25
25
                                   "code and message must not be set.")
 
26
 
 
27
    def __str__(self):
 
28
        # This avoids an exception when twisted logger logs the message, as it
 
29
        # currently doesn't support unicode.
 
30
        if self.message is not None:
 
31
            return self.message.encode("ascii", "replace")
 
32
        return ""