PageRenderTime 35ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/ovsdb-error.h

https://github.com/noironetworks/ovs
C++ Header | 69 lines | 34 code | 13 blank | 22 comment | 0 complexity | da740b6dfc939157cd2e0e75e957fe07 MD5 | raw file
 1/* Copyright (c) 2009, 2010, 2011 Nicira, Inc.
 2 *
 3 * Licensed under the Apache License, Version 2.0 (the "License");
 4 * you may not use this file except in compliance with the License.
 5 * You may obtain a copy of the License at:
 6 *
 7 *     http://www.apache.org/licenses/LICENSE-2.0
 8 *
 9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OVSDB_ERROR_H
17#define OVSDB_ERROR_H 1
18
19#include "compiler.h"
20
21struct json;
22
23struct ovsdb_error *ovsdb_error(const char *tag, const char *details, ...)
24    OVS_PRINTF_FORMAT(2, 3)
25    OVS_WARN_UNUSED_RESULT;
26struct ovsdb_error *ovsdb_io_error(int error, const char *details, ...)
27    OVS_PRINTF_FORMAT(2, 3)
28    OVS_WARN_UNUSED_RESULT;
29struct ovsdb_error *ovsdb_syntax_error(const struct json *, const char *tag,
30                                       const char *details, ...)
31    OVS_PRINTF_FORMAT(3, 4)
32    OVS_WARN_UNUSED_RESULT;
33
34struct ovsdb_error *ovsdb_wrap_error(struct ovsdb_error *error,
35                                     const char *details, ...)
36    OVS_PRINTF_FORMAT(2, 3);
37
38struct ovsdb_error *ovsdb_internal_error(struct ovsdb_error *error,
39                                         const char *file, int line,
40                                         const char *details, ...)
41    OVS_PRINTF_FORMAT(4, 5)
42    OVS_WARN_UNUSED_RESULT;
43
44/* Returns a pointer to an ovsdb_error that represents an internal error for
45 * the current file name and line number with MSG as the associated message.
46 * The caller is responsible for freeing the internal error. */
47#define OVSDB_BUG(MSG)                                      \
48    ovsdb_internal_error(NULL, __FILE__, __LINE__, "%s", MSG)
49
50/* Returns a pointer to an ovsdb_error that represents an internal error for
51 * the current file name and line number, with MSG as the associated message.
52 * If ERROR is nonnull then the internal error is wrapped around ERROR.  Takes
53 * ownership of ERROR.  The caller is responsible for freeing the returned
54 * error. */
55#define OVSDB_WRAP_BUG(MSG, ERROR)                          \
56    ovsdb_internal_error(ERROR, __FILE__, __LINE__, "%s", MSG)
57
58void ovsdb_error_destroy(struct ovsdb_error *);
59struct ovsdb_error *ovsdb_error_clone(const struct ovsdb_error *)
60    OVS_WARN_UNUSED_RESULT;
61
62char *ovsdb_error_to_string(const struct ovsdb_error *);
63struct json *ovsdb_error_to_json(const struct ovsdb_error *);
64
65const char *ovsdb_error_get_tag(const struct ovsdb_error *);
66
67void ovsdb_error_assert(struct ovsdb_error *);
68
69#endif /* ovsdb-error.h */