Midgard2 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#include <midgard/midgard.h> #define MIDGARD_GENERIC_ERROR GQuark midgard_error_generic (void
); const gchar * midgard_error_string (GQuark domain
,gint errcode
); void midgard_set_error (MidgardConnection *mgd
,GQuark domain
,gint errcode
,const gchar *msg
,...
); void midgard_error_default_log (const gchar *domain
,GLogLevelFlags level
,const gchar *msg
,gpointer ptr
); gint midgard_error_parse_loglevel (const gchar *levelstring
); #define MIDGARD_ERRNO_SET (str, errcode)
GQuark midgard_error_generic (void
);
GQuark for Midgard Error. It's used by Midgard Error implementation, and probably not needed to use by any application.
Returns : |
MGD_GENERIC_ERROR GQuark |
const gchar * midgard_error_string (GQuark domain
,gint errcode
);
Get error message for the given error code.
|
GQuark which represents MidgardError domain. |
|
MidgardErrorGeneric enum value. |
Returns : |
error messages which is owned by midgard-core and should not be freed. |
void midgard_set_error (MidgardConnection *mgd
,GQuark domain
,gint errcode
,const gchar *msg
,...
);
This function sets internal error constant, and creates new error message.
User defined message is appended to internal one.
Any message created by application ( and its corresponding constant ) are destroyed
and reset to MGD_ERR_OK when any API function is invoked.
Second domain
parameter is optional , and can be safely defined as NULL for
MGD_GENERIC_ERROR domain.
Example 5.
void set_wrong_property(MidgardConnection *mgd, gchar *prop) { midgard_set_error(mgd, NULL, MGD_ERR_INVALID_PROPERTY_VALUE, "My application doesn't accept %s property", prop); }
|
MidgardConnection instance |
|
GQuark which represents MidgardError domain |
|
MidgardErrorGeneric enum value |
|
a message which should be appended to string represented by errcode |
|
message argument list ( if required ) |
void midgard_error_default_log (const gchar *domain
,GLogLevelFlags level
,const gchar *msg
,gpointer ptr
);
ptr
pointer may be a pointer to MidgardConnection or MidgardTypeHolder
structure. This function checks pointer type using MIDGARD_IS_CONNECTION
convention macro. Next midgard_connection_get_loglevel is called to get loglevel.
If MidgardConnection check fails , a typecast to MidgardTypeHolder is made.
In this case, level member is used to get loglevel.
You are responsible to correctly set MidgardConnection or MidgardTypeHolder before passing ptr argument. The main approach is to follow configuration's loglevel even if MidgardConnection pointer is not yet available.
see
midgard_connection_set_loglevel()
to set log level.
|
domain for the given log message |
|
GLogLevelFlags |
|
log message |
|
pointer to structure which holds loglevel |
gint midgard_error_parse_loglevel (const gchar *levelstring
);
This function returns level registered in GLib.
|
string which should be parsed |
Returns : |
GLogLevelFlags or -1 on failure |