(self)
| 74 | """Generic error class.""" |
| 75 | |
| 76 | def _message(self) -> str: |
| 77 | # rules: |
| 78 | # |
| 79 | # 1. single arg string will usually be a unicode |
| 80 | # object, but since __str__() must return unicode, check for |
| 81 | # bytestring just in case |
| 82 | # |
| 83 | # 2. for multiple self.args, this is not a case in current |
| 84 | # SQLAlchemy though this is happening in at least one known external |
| 85 | # library, call str() which does a repr(). |
| 86 | # |
| 87 | text: str |
| 88 | |
| 89 | if len(self.args) == 1: |
| 90 | arg_text = self.args[0] |
| 91 | |
| 92 | if isinstance(arg_text, bytes): |
| 93 | text = compat.decode_backslashreplace(arg_text, "utf-8") |
| 94 | # This is for when the argument is not a string of any sort. |
| 95 | # Otherwise, converting this exception to string would fail for |
| 96 | # non-string arguments. |
| 97 | else: |
| 98 | text = str(arg_text) |
| 99 | |
| 100 | return text |
| 101 | else: |
| 102 | # this is not a normal case within SQLAlchemy but is here for |
| 103 | # compatibility with Exception.args - the str() comes out as |
| 104 | # a repr() of the tuple |
| 105 | return str(self.args) |
| 106 | |
| 107 | def _sql_message(self) -> str: |
| 108 | message = self._message() |
no outgoing calls
no test coverage detected