Errors

Errors — error definitions and utilities

Synopsis

#include <gum/common/gum-error.h>

#define             GUM_ERROR
#define             GUM_GET_ERROR_FOR_ID                (code,
                                                         message,
                                                         ...)
#define             GUM_RETURN_WITH_ERROR               (code,
                                                         err_str,
                                                         err,
                                                         retval)
#define             GUM_SET_ERROR                       (code,
                                                         err_str,
                                                         err,
                                                         retvar,
                                                         retval)
enum                GumError;
GError *            gum_error_new_from_variant          (GVariant *var);
GQuark              gum_error_quark                     (void);
GVariant *          gum_error_to_variant                (GError *error);

Description

This file provides Gum error definitions and utilities. When creating an error, use GUM_ERROR for the error domain and errors from GumError for the error code.

    GError* err = g_error_new(GUM_ERROR, GUM_ERROR_USER_ALREADY_EXISTS,
    "User already exists");

Details

GUM_ERROR

#define GUM_ERROR   (gum_error_quark())

This macro should be used when creating a GError (for example with g_error_new()).


GUM_GET_ERROR_FOR_ID()

#define             GUM_GET_ERROR_FOR_ID(code, message, args...)

A helper macro that creates a GError with the proper gum domain

code :

A GumError specifying the error

message :

Format string for the error message

... :

parameters for the error string

GUM_RETURN_WITH_ERROR()

#define             GUM_RETURN_WITH_ERROR(code, err_str, err, retval)

A helper macro that creates a GError with the proper gum domain, output the error message to logs, and returns with specified retval.

code :

the error code as listed in GumError

err_str :

the error message to be set for the GError

err :

a GError

retval :

value to be used on return

GUM_SET_ERROR()

#define             GUM_SET_ERROR(code, err_str, err, retvar, retval)

A helper macro that creates a GError with the proper gum domain, output the error message to logs, and sets the specified retval to retvar.

code :

the error code as listed in GumError

err_str :

the error message to be set for the GError

err :

a GError

retvar :

return variable to hold the return value

retval :

return value to be set to the return variable

enum GumError

typedef enum {
    GUM_ERROR_NONE,

    GUM_ERROR_UNKNOWN = 1,
    GUM_ERROR_INTERNAL_SERVER,
    GUM_ERROR_PERMISSION_DENIED,

    GUM_ERROR_USER_ALREADY_EXISTS = 32,
    GUM_ERROR_USER_GROUP_ADD_FAILURE,
    GUM_ERROR_USER_UID_NOT_AVAILABLE,
    GUM_ERROR_USER_INVALID_USER_TYPE,
    GUM_ERROR_USER_SECRET_ENCRYPT_FAILURE,
    GUM_ERROR_USER_NOT_FOUND,
    GUM_ERROR_USER_INVALID_DATA,
    GUM_ERROR_USER_GROUP_DELETE_FAILURE,
    GUM_ERROR_USER_SELF_DESTRUCTION,
    GUM_ERROR_USER_SESSION_TERM_FAILURE,
    GUM_ERROR_USER_NO_CHANGES,
    GUM_ERROR_USER_LOCK_FAILURE,

    GUM_ERROR_GROUP_ALREADY_EXISTS = 64,
    GUM_ERROR_GROUP_GID_NOT_AVAILABLE,
    GUM_ERROR_GROUP_INVALID_GROUP_TYPE,
    GUM_ERROR_GROUP_SECRET_ENCRYPT_FAILURE,
    GUM_ERROR_GROUP_NOT_FOUND,
    GUM_ERROR_GROUP_USER_ALREADY_A_MEMBER,
    GUM_ERROR_GROUP_INVALID_DATA,
    GUM_ERROR_GROUP_SELF_DESTRUCTION,
    GUM_ERROR_GROUP_HAS_USER,
    GUM_ERROR_GROUP_NO_CHANGES,

    GUM_ERROR_DB_ALREADY_LOCKED = 90,
    GUM_ERROR_FILE_OPEN,
    GUM_ERROR_FILE_ATTRIBUTE,
    GUM_ERROR_FILE_MOVE,
    GUM_ERROR_FILE_WRITE,
    GUM_ERROR_HOME_DIR_CREATE_FAILURE,
    GUM_ERROR_HOME_DIR_DELETE_FAILURE,
    GUM_ERROR_HOME_DIR_COPY_FAILURE,

    GUM_ERROR_INVALID_NAME = 120,
    GUM_ERROR_INVALID_NICKNAME,

    GUM_ERROR_INVALID_SECRET = 130,

    GUM_ERROR_INVALID_STR = 140,
    GUM_ERROR_INVALID_STR_LEN,

    GUM_ERROR_INVALID_INPUT = 160,

    GUM_ERROR_USER_ERR = 400
} GumError;

This enumeration provides a list of errors

GUM_ERROR_NONE

No error

GUM_ERROR_UNKNOWN

Catch-all for errors not distinguished by another error code

GUM_ERROR_INTERNAL_SERVER

Server internal error

GUM_ERROR_PERMISSION_DENIED

The operation cannot be performed due to insufficient client permissions

GUM_ERROR_USER_ALREADY_EXISTS

User already exists

GUM_ERROR_USER_GROUP_ADD_FAILURE

Adding/creating groups for the user failure

GUM_ERROR_USER_UID_NOT_AVAILABLE

UID not available in the defined range

GUM_ERROR_USER_INVALID_USER_TYPE

Usertype is not set

GUM_ERROR_USER_SECRET_ENCRYPT_FAILURE

Encryption of secret failure

GUM_ERROR_USER_NOT_FOUND

User not found

GUM_ERROR_USER_INVALID_DATA

Invalid data provided in the request

GUM_ERROR_USER_GROUP_DELETE_FAILURE

Deleting group for the user failure

GUM_ERROR_USER_SELF_DESTRUCTION

Self-destruction is not allowed

GUM_ERROR_USER_SESSION_TERM_FAILURE

Session termination of a user failure

GUM_ERROR_USER_NO_CHANGES

No changes specified in the user update request

GUM_ERROR_USER_LOCK_FAILURE

Unable to lock the user account before doing any changes

GUM_ERROR_GROUP_ALREADY_EXISTS

Group already exists

GUM_ERROR_GROUP_GID_NOT_AVAILABLE

GID mot available in the defined range

GUM_ERROR_GROUP_INVALID_GROUP_TYPE

Group type not set

GUM_ERROR_GROUP_SECRET_ENCRYPT_FAILURE

Encryption of group secret failure

GUM_ERROR_GROUP_NOT_FOUND

Group not found

GUM_ERROR_GROUP_USER_ALREADY_A_MEMBER

User is already a member of the group

GUM_ERROR_GROUP_INVALID_DATA

Invalid data is specified in the request

GUM_ERROR_GROUP_SELF_DESTRUCTION

Self-destruction is not allowed

GUM_ERROR_GROUP_HAS_USER

Group has (other) user(s)

GUM_ERROR_GROUP_NO_CHANGES

No changes specified in the group update request

GUM_ERROR_DB_ALREADY_LOCKED

Database is already locked

GUM_ERROR_FILE_OPEN

File open error

GUM_ERROR_FILE_ATTRIBUTE

File attribute error

GUM_ERROR_FILE_MOVE

File move error

GUM_ERROR_FILE_WRITE

File write error

GUM_ERROR_HOME_DIR_CREATE_FAILURE

Directory create failure

GUM_ERROR_HOME_DIR_DELETE_FAILURE

Directory delete failure

GUM_ERROR_HOME_DIR_COPY_FAILURE

Directory copy failure

GUM_ERROR_INVALID_NAME

Invalid name specified

GUM_ERROR_INVALID_NICKNAME

Invalid nickname specified

GUM_ERROR_INVALID_SECRET

Invalid secret specified

GUM_ERROR_INVALID_STR

Invalid string specified

GUM_ERROR_INVALID_STR_LEN

Invalid string length

GUM_ERROR_INVALID_INPUT

Invalid input specified

GUM_ERROR_USER_ERR

Placeholder to rearrange enumeration - User space specific

gum_error_new_from_variant ()

GError *            gum_error_new_from_variant          (GVariant *var);

Converts the GVariant to GError.

var :

instance of GVariant. [transfer none]

Returns :

GError object if successful, NULL otherwise. [transfer full]

gum_error_quark ()

GQuark              gum_error_quark                     (void);

Creates and returns a domain for Gum errors.

Returns :

GQuark for Gum errors

gum_error_to_variant ()

GVariant *          gum_error_to_variant                (GError *error);

Converts the GError to GVariant.

error :

instance of GError. [transfer none]

Returns :

(transfer full) GVariant object if successful, NULL otherwise.