<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_exception(exc, uuid=None):
 """ Serialize an exception into a result :param Exception exc: Exception raised :param str uuid: Current Kafka :class:`kser.transport.Message` uuid :rtype: :class:`kser.result.Result` """

        if not isinstance(exc, Error):
            exc = Error(code=500, message=str(exc))

        return Result(
            uuid=exc.extra.get("uuid", uuid or random_uuid()),
            retcode=exc.code, stderr=exc.message,
            retval=dict(error=ErrorSchema().dump(exc))
        )