Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
error: changed macro naming of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ZronekM committed Jun 22, 2019
1 parent 099626f commit 2c2813c
Show file tree
Hide file tree
Showing 94 changed files with 646 additions and 644 deletions.
4 changes: 2 additions & 2 deletions doc/tutorials/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Basically the implementation of `elektraLineSet` can be described with the follo
// open the file
if (error)
{
ELEKTRA_SET_ERROR(RESOURCE_CODE, parentKey, keyString(parentKey));
ELEKTRA_SET_ERROR(ELEKTRA_ERROR_RESOURCE, parentKey, keyString(parentKey));
}
for (/* each key */)
{
Expand Down Expand Up @@ -404,7 +404,7 @@ int elektraLineCheckConfig (Key * errorKey, KeySet * conf)
const char * value = keyString (cur);
if (strlen (value) > 3)
{
ELEKTRA_SET_ERRORF (PARSING_CODE, errorKey,
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_PARSING, errorKey,
"value %s is more than 3 characters long",
value);
return -1; // The configuration was not OK and could not be fixed
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/cpp/include/kdbplugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Delegator
catch (const char * msg)
{
#ifdef KDBERRORS_H
ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not create C++ plugin: %s", msg);
ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create C++ plugin: %s", msg);
#endif
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/error/exporterrors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ static ostream & printKDBErrors (ostream & os, parse_t & p)
continue;
}

os << "#define " << p[i]["macro"] << " " << p[i]["number"] << "" << endl;
os << "#define ELEKTRA_WARNING_" << p[i]["macro"] << " " << p[i]["number"] << "" << endl;
os << "#define ELEKTRA_ERROR_" << p[i]["macro"] << " " << p[i]["number"] << "" << endl;
}

os << endl << endl;
Expand Down
16 changes: 8 additions & 8 deletions src/error/specification
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ ignore:true

number:01100
description:Resource
macro:RESOURCE_CODE
macro:RESOURCE

number:01200
description:Parsing
macro:PARSING_CODE
macro:PARSING

number:01300
description:Installation
macro:INSTALLATION_CODE
macro:INSTALLATION

number:01400
description:Logical
macro:LOGICAL_CODE
macro:LOGICAL

number:02000
description:Conflict
macro:CONFLICT_CODE
macro:CONFLICT

number:03000
description:Timeout
macro:TIMEOUT_CODE
macro:TIMEOUT

number:04100
description:Validation Syntactic
macro:VALIDATION_SYNTACTIC_CODE
macro:VALIDATION_SYNTACTIC

number:04200
description:Validation Semantic
macro:VALIDATION_SEMANTIC_CODE
macro:VALIDATION_SEMANTIC
16 changes: 8 additions & 8 deletions src/include/kdbmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,28 @@
do \
{ \
if (errno == EACCES) \
ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, \
"Insufficient permissions to open configuration file for reading. Reason: %s. You might want " \
"to retry as root or change access using chmod.", \
strerror (errno)); \
else \
ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, "Could not open configuration file for reading. Reason: %s", \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, "Could not open configuration file for reading. Reason: %s", \
strerror (errno)); \
} while (0)

#define ELEKTRA_SET_ERROR_SET(parentKey) \
do \
{ \
if (errno == EACCES) \
ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, \
"Insufficient permissions to open configuration file for writing. You might want to retry as " \
"root. Errno: %s", \
strerror (errno)); \
else \
ELEKTRA_SET_ERRORF (RESOURCE_CODE, parentKey, ":Could not open file for writing %s", strerror (errno)); \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, parentKey, ":Could not open file for writing %s", strerror (errno)); \
} while (0)

#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_ERRORF (RESOURCE_CODE, key, "Unable to allocate %zu bytes.", size);
#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_RESOURCE, key, "Unable to allocate %zu bytes.", size);

/**
* @brief Sets error 84 if info != returned
Expand All @@ -80,15 +80,15 @@
Key * c = ksNext (info); \
if (!c) \
{ \
ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \
"Read only plugin, kdbSet not supported but the key %s (value %s) was added", \
keyName (k), keyString (k)); \
ksDel (info); \
return -1; \
} \
if (strcmp (keyName (k), keyName (c)) || strcmp (keyString (k), keyString (c))) \
{ \
ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \
"Read only plugin, kdbSet not supported but the key %s (expected %s) was modified to " \
"%s (expected %s)", \
keyName (k), keyName (c), keyString (k), keyString (c)); \
Expand All @@ -98,7 +98,7 @@
} \
if ((k = ksNext (info)) != 0) \
{ \
ELEKTRA_SET_ERRORF (INSTALLATION_CODE, error, \
ELEKTRA_SET_ERRORF (ELEKTRA_ERROR_INSTALLATION, error, \
"Read only plugin, kdbSet not supported but the key %s (value %s) was removed", keyName (k), \
keyString (k)); \
ksDel (info); \
Expand Down
12 changes: 6 additions & 6 deletions src/libs/elektra/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key

if (!foundMountpoint)
{
ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not find mountpoint within root %s", keyName (root));
ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not find mountpoint within root %s", keyName (root));
return -1;
}

Expand All @@ -91,7 +91,7 @@ int elektraBackendSetMountpoint (Backend * backend, KeySet * elektraConfig, Key

if (!backend->mountpoint)
{
ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Could not create mountpoint with name %s and value %s",
ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Could not create mountpoint with name %s and value %s",
keyString (foundMountpoint), keyBaseName (root));
return -1;
}
Expand Down Expand Up @@ -202,7 +202,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global
errorKey) == -1)
{
if (!failure)
ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for error failed");
ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for error failed");
failure = 1;
}
}
Expand All @@ -212,7 +212,7 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global
errorKey) == -1)
{
if (!failure)
ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for get failed");
ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for get failed");
failure = 1;
}
}
Expand All @@ -227,15 +227,15 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global
errorKey) == -1)
{
if (!failure)
ELEKTRA_ADD_WARNING (INSTALLATION_CODE, errorKey, "elektraProcessPlugins for set failed");
ELEKTRA_ADD_WARNING (ELEKTRA_WARNING_INSTALLATION, errorKey, "elektraProcessPlugins for set failed");
failure = 1;
}
}
else
{
// no one cares about that config
if (!failure)
ELEKTRA_ADD_WARNINGF (INSTALLATION_CODE, errorKey, "Unrecognised Config Tree: %s",
ELEKTRA_ADD_WARNINGF (ELEKTRA_WARNING_INSTALLATION, errorKey, "Unrecognised Config Tree: %s",
keyBaseName (cur));
ksDel (cut);
}
Expand Down
Loading

0 comments on commit 2c2813c

Please sign in to comment.