def _check_call(ret):
    """Check the return value of C API call

    This function will raise exception when error occurs.
    Wrap every API call with this function

    Parameters
    ----------
    ret : int
        return value from API calls
    """
    if ret != 0:
        msg = ""
        # raise XLearnError()
        _LIB.XLearnGetLastError.restype = ctypes.POINTER(ctypes.c_ubyte)
        ptr = _LIB.XLearnGetLastError()
        idx = 0
        while(ptr[idx] != 0):
            msg += chr(ptr[idx])
            idx += 1
        raise XLearnError(msg)