virterror_internal.h 3.8 KB
Newer Older
1 2 3
/*
 * virterror.h: internal error handling
 *
J
Jim Meyering 已提交
4
 * Copyright (C) 2006-2009 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 */

#ifndef __VIRT_ERROR_H_
#define __VIRT_ERROR_H_

#include "internal.h"

extern virErrorFunc virErrorHandler;
extern void *virUserData;

/************************************************************************
 *									*
 *		API for error handling					*
 *									*
 ************************************************************************/
35
int virErrorInitialize(void);
D
Daniel P. Berrange 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
void virRaiseErrorFull(virConnectPtr conn,
                       const char *filename,
                       const char *funcname,
                       size_t linenr,
                       int domain,
                       int code,
                       virErrorLevel level,
                       const char *str1,
                       const char *str2,
                       const char *str3,
                       int int1,
                       int int2,
                       const char *fmt, ...)
    ATTRIBUTE_FORMAT(printf, 13, 14);

/* Includes 'dom' and 'net' for compatbility, but they're ignored */
#define virRaiseError(conn, dom, net, domain, code, level,              \
                      str1, str2, str3, int1, int2, msg, ...)           \
    virRaiseErrorFull(conn, __FILE__, __FUNCTION__, __LINE__,           \
                      domain, code, level, str1, str2, str3, int1, int2, \
                      msg, __VA_ARGS__)

58 59 60 61
const char *virErrorMsg(virErrorNumber error, const char *info);
void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,
                          const char *filename ATTRIBUTE_UNUSED,
                          const char *funcname ATTRIBUTE_UNUSED,
62
                          size_t linenr ATTRIBUTE_UNUSED,
63 64 65
                          const char *fmt, ...)
  ATTRIBUTE_FORMAT(printf, 7, 8);

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
void virReportSystemErrorFull(virConnectPtr conn,
                              int domcode,
                              int theerrno,
                              const char *filename,
                              const char *funcname,
                              size_t linenr,
                              const char *fmt, ...)
    ATTRIBUTE_FORMAT(printf, 7, 8);

#define virReportSystemError(conn, theerrno, fmt,...)             \
    virReportSystemErrorFull((conn),                              \
                             VIR_FROM_THIS,                       \
                             (theerrno),                          \
                             __FILE__, __FUNCTION__, __LINE__,    \
                             (fmt), __VA_ARGS__)

void virReportOOMErrorFull(virConnectPtr conn,
                           int domcode,
                           const char *filename,
                           const char *funcname,
                           size_t linenr);

#define virReportOOMError(conn)                         \
    virReportOOMErrorFull((conn), VIR_FROM_THIS,        \
                     __FILE__, __FUNCTION__, __LINE__)

92

93 94
void virSetGlobalError(void);
void virSetConnError(virConnectPtr conn);
J
Jim Meyering 已提交
95
const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen);
96

97
#endif