Skip to content

Commit

Permalink
add dunder method for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahad-10 committed Dec 19, 2024
1 parent 1b9a4d2 commit e6f1cff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions wampproto/messages/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,14 @@ def marshal(self) -> list[Any]:
message.append(self.kwargs)

return message

def __str__(self) -> str:
error = self.uri
if self.args is not None:
args = ", ".join(str(arg) for arg in self.args)
error += f": {args}"
if self.kwargs is not None:
kwargs = ", ".join(f"{key}={value}" for key, value in self.kwargs.items())
error += f": {kwargs}"

return error

0 comments on commit e6f1cff

Please sign in to comment.