@classmethod
def from_api_error(cls, e):
    """Create a new :class:`ApiErrorCode` instance from an
        :class:`avalon.exc.ApiError` exception.

        :param avalon.exc.ApiError e: Exception to create the
            error from
        :return: An API error code representing the given exception
        :rtype: ApiErrorCode
        """
    err = cls()
    err.code = e.code
    err.message = e.message
    err.message_key = e.message_key
    err.payload = e.payload
    return err
