Elektra error codes.
More...
#include "elektra/conversion.h"
#include "elektra/error.h"
#include "kdberrors.h"
#include "kdbhelper.h"
#include "kdbprivate.h"
#include <string.h>
|
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 * | elektraErrorKeyNotFound (const char *keyname) |
| Creates a "Key not found" error. More...
|
|
ElektraError * | elektraErrorWrongType (const char *keyname, KDBType expectedType, KDBType actualType) |
| Creates a "Wrong type" error. More...
|
|
ElektraError * | elektraErrorNullError (const char *function) |
| Creates a "Null error argument" error. More...
|
|
ElektraError * | elektraErrorConversionToString (KDBType sourceType, const char *keyname) |
| Creates a "Conversion to string failed" error. More...
|
|
ElektraError * | elektraErrorConversionFromString (KDBType targetType, const char *keyname, const char *sourceValue) |
| Creates a "Conversion from string failed" error. More...
|
|
ElektraError * | elektraErrorMinimalValidationFailed (const char *application) |
| Creates a "minimal validation failed" error. 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.
|
|
Elektra error codes.
- Copyright
- BSD License (see doc/LICENSE.md or http://www.libelektra.org)
◆ 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
-
error | The error to which warning shall be added. |
warning | The warning to add. Once added it is owned by error . DO NOT call elektraErrorReset() on it afterwards. |
◆ elektraErrorConversionFromString()
ElektraError* elektraErrorConversionFromString |
( |
KDBType |
targetType, |
|
|
const char * |
keyname, |
|
|
const char * |
sourceValue |
|
) |
| |
Creates a "Conversion from string failed" error.
- Parameters
-
targetType | The type into which sourceValue couldn't be converted. |
keyname | The name of the key that couldn't be converted. |
sourceValue | The value that couldn't be converted. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ elektraErrorConversionToString()
ElektraError* elektraErrorConversionToString |
( |
KDBType |
sourceType, |
|
|
const char * |
keyname |
|
) |
| |
Creates a "Conversion to string failed" error.
- Parameters
-
sourceType | The type which failed to be converted to string. |
keyname | The name of the key that couldn't be converted. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ 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
-
code | The error code of the error. Must be compile-time constant. |
description | The description of the error. Will be copied and stored in the struct. |
module | The module that raised the error. Must be compile-time constant. |
file | The file that raised the error. Must be compile-time constant. |
line | The line in which the error was raised. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ 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
-
key | The to extract error and warnings from. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ elektraErrorKeyNotFound()
ElektraError* elektraErrorKeyNotFound |
( |
const char * |
keyname | ) |
|
Creates a "Key not found" error.
- Parameters
-
keyname | The name of the key that wasn't found. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ elektraErrorMinimalValidationFailed()
ElektraError* elektraErrorMinimalValidationFailed |
( |
const char * |
application | ) |
|
Creates a "minimal validation failed" error.
- Parameters
-
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ elektraErrorNullError()
ElektraError* elektraErrorNullError |
( |
const char * |
function | ) |
|
Creates a "Null error argument" error.
- Parameters
-
function | The name of the function that was called with a null pointer error argument. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).
◆ elektraErrorWrongType()
ElektraError* elektraErrorWrongType |
( |
const char * |
keyname, |
|
|
KDBType |
expectedType, |
|
|
KDBType |
actualType |
|
) |
| |
Creates a "Wrong type" error.
- Parameters
-
keyname | The name of the key that had the wrong type. |
expectedType | The type that was expected. |
actualType | The type that was actually found. |
- Returns
- A newly allocated ElektraError (free with elektraErrorReset()).