static void virKeyFileErrorHelper(const char *file, const char *func, size_t line, virKeyFileParserCtxtPtr ctxt, virErrorNumber error, const char *info) { /* Construct the string 'filename:line: info' if we have that. */ if (ctxt && ctxt->filename) { virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, _("%s:%zu: %s '%s'"), ctxt->filename, ctxt->line, info, ctxt->cur); } else { virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, "%s", info); } }
/* Error handling function returns error messages from the server if any */ void xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum, const char *buf, const char *filename, const char *func, size_t lineno) { struct _xenapiPrivate *priv = conn->privateData; if (buf == NULL && priv != NULL && priv->session != NULL) { char *ret = returnErrorFromSession(priv->session); virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret); xen_session_clear_error(priv->session); VIR_FREE(ret); } else { virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf); } }
static void virConfErrorHelper(const char *file, const char *func, size_t line, virConfParserCtxtPtr ctxt, virErrorNumber error, const char *info) { if (error == VIR_ERR_OK) return; /* Construct the string 'filename:line: info' if we have that. */ if (ctxt && ctxt->filename) { virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, _("%s:%d: %s"), ctxt->filename, ctxt->line, info); } else { virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, "%s", info); } }
/** * virBufferCheckErrorInternal: * @buf: the buffer * * Report an error if the buffer is in an error state. * * Return -1 if an error has been reported, 0 otherwise. */ int virBufferCheckErrorInternal(const virBuffer *buf, int domcode, const char *filename, const char *funcname, size_t linenr) { if (buf->error == 0) return 0; if (buf->error == ENOMEM) { virReportOOMErrorFull(domcode, filename, funcname, linenr); errno = ENOMEM; } else { virReportErrorHelper(domcode, VIR_ERR_INTERNAL_ERROR, filename, funcname, linenr, "%s", _("Invalid buffer API usage")); errno = EINVAL; } return -1; }