Elektra  0.9.0
Functions
elektra_error.c File Reference

Elektra error codes. More...

#include "elektra/conversion.h"
#include "elektra/error.h"
#include "kdberrors.h"
#include "kdbhelper.h"
#include "kdbprivate.h"
#include <string.h>
Include dependency graph for elektra_error.c:

Functions

ElektraError * elektraErrorCreate (const char *code, const char *description, const char *module, const char *file, kdb_long_t line)
 Creates a new ElektraError using the provided values. More...
 
void elektraErrorAddWarning (ElektraError *error, ElektraError *warning)
 Adds a warning to an existing ElektraError struct. More...
 
ElektraError * elektraErrorFromKey (Key *key)
 Extracts the error and all warnings from the given key. More...
 
ElektraError * elektraErrorPureWarning (void)
 Creates a dummy ElektraError struct to store warnings in. More...
 
const char * elektraErrorCode (const ElektraError *error)
 
const char * elektraErrorDescription (const ElektraError *error)
 
void elektraErrorReset (ElektraError **error)
 Frees the memory used by the error and sets the referenced error variable to NULL.
 

Detailed Description

Elektra error codes.

Function Documentation

◆ elektraErrorAddWarning()

void elektraErrorAddWarning ( ElektraError *  error,
ElektraError *  warning 
)

Adds a warning to an existing ElektraError struct.

If you want to report a warning without an error, create a dummy error with elektraErrorPureWarning() and then add a warning to it.

Parameters
errorThe error to which warning shall be added.
warningThe warning to add. Once added it is owned by error. Do not call elektraErrorReset() on it afterwards.

◆ elektraErrorCreate()

ElektraError* elektraErrorCreate ( const char *  code,
const char *  description,
const char *  module,
const char *  file,
kdb_long_t  line 
)

Creates a new ElektraError using the provided values.

The returned value will be allocated with elektraCalloc().

Parameters
codeThe error code of the error. Must be compile-time constant.
descriptionThe description of the error. Will be copied and stored in the struct.
moduleThe module that raised the error. Must be compile-time constant.
fileThe file that raised the error. Must be compile-time constant.
lineThe line in which the error was raised.
Returns
A newly allocated ElektraError (free with elektraFree()).

◆ elektraErrorFromKey()

ElektraError* elektraErrorFromKey ( Key *  key)

Extracts the error and all warnings from the given key.

If no error exists, a pure warning error will be used.

See also
elektraErrorPureWarning
Parameters
keyThe to extract error and warnings from.
Returns
A newly allocated ElektraError (free with elektraFree()).