<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_dict(self):
 """Convert Exception class to a Python dictionary."""

        val = dict(self.payload or ())
        if self.message:
            val['message'] = self.message
        return val