1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* 3 * lt-error.h 4 * Copyright (C) 2011-2012 Akira TAGOH 5 * 6 * Authors: 7 * Akira TAGOH <akira@tagoh.org> 8 * 9 * You may distribute under the terms of either the GNU 10 * Lesser General Public License or the Mozilla Public 11 * License, as specified in the README file. 12 */ 13 #if !defined (__LANGTAG_H__INSIDE) && !defined (__LANGTAG_COMPILATION) 14 #error "Only <liblangtag/langtag.h> can be included directly." 15 #endif 16 17 #ifndef __LT_ERROR_H__ 18 #define __LT_ERROR_H__ 19 20 #include <liblangtag/lt-macros.h> 21 22 LT_BEGIN_DECLS 23 24 /** 25 * lt_error_type_t: 26 * @LT_ERR_UNKNOWN: unknown error happened. 27 * @LT_ERR_SUCCESS: an operation is succeeded. 28 * @LT_ERR_OOM: Out of memory occurred. 29 * @LT_ERR_FAIL_ON_XML: an error happened in libxml2. 30 * @LT_ERR_EOT: No tokens to scan. 31 * @LT_ERR_FAIL_ON_SCANNER: an error happened in the scanner. 32 * @LT_ERR_NO_TAG: No tags to process. 33 * @LT_ERR_INVALID: Invalid operation. 34 * @LT_ERR_ANY: No real error, but just a flag to query all of errors or ask 35 * if any errors happen 36 * 37 * Error code used in this library. 38 */ 39 enum _lt_error_type_t { 40 LT_ERR_UNKNOWN = -1, 41 LT_ERR_SUCCESS = 0, 42 LT_ERR_OOM, 43 LT_ERR_FAIL_ON_XML, 44 LT_ERR_EOT, 45 LT_ERR_FAIL_ON_SCANNER, 46 LT_ERR_NO_TAG, 47 LT_ERR_INVALID, 48 LT_ERR_ANY 49 }; 50 51 /** 52 * lt_error_t: 53 * 54 * All the fields in the <structname>lt_error_t</structname> 55 * structure are private to the #lt_error_t implementation. 56 */ 57 typedef struct _lt_error_t lt_error_t; 58 typedef enum _lt_error_type_t lt_error_type_t; 59 60 lt_error_t *lt_error_new (void); 61 lt_error_t *lt_error_ref (lt_error_t *error); 62 void lt_error_unref (lt_error_t *error); 63 lt_error_t *lt_error_set (lt_error_t **error, 64 lt_error_type_t type, 65 const char *message, 66 ...) LT_GNUC_PRINTF (3, 4); 67 void lt_error_clear (lt_error_t *error); 68 lt_bool_t lt_error_is_set(lt_error_t *error, 69 lt_error_type_t type); 70 void lt_error_print (lt_error_t *error, 71 lt_error_type_t type); 72 73 LT_END_DECLS 74 75 #endif /* __LT_ERROR_H__ */ 76