MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _message

Method _message

lib/sqlalchemy/exc.py:76–105  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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()

Callers 2

_sql_messageMethod · 0.95
_sql_messageMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected