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

Commit

Permalink
error: migrated GENERAL_RESOURCE, removed OUT_OF_RANGE, removed TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
ZronekM committed Jun 22, 2019
1 parent 13fe96d commit 0101329
Show file tree
Hide file tree
Showing 62 changed files with 222 additions and 231 deletions.
2 changes: 1 addition & 1 deletion 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_GENERAL_RESOURCE_ERROR( parentKey, keyString(parentKey));
ELEKTRA_SET_RESOURCE_ERROR( parentKey, keyString(parentKey));
}
for (/* each key */)
{
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sudo kdb mount validation.dump user/tests/together dump validation
kdb vset user/tests/together/test 123 "[1-9][0-9]*" "Not a number"
kdb set user/tests/together/test abc
# STDERR: Sorry, module validation issued the error.*
# ERROR:C04100
# ERROR:C03100
# RET:5
```

Expand Down Expand Up @@ -265,7 +265,7 @@ you can run into [this](https://github.com/ElektraInitiative/libelektra/issues/2
kdb set /tests/tutorial/links/url "invalid url"
# STDOUT-REGEX: Using name (user|system)/tests/tutorial/links/url
# STDERR: .*Validation Syntactic.*not a valid URL.*
# ERROR: C04100
# ERROR: C03100
# RET: 5
```

Expand Down Expand Up @@ -298,13 +298,13 @@ There are many ways to do so directly supported by [the spec plugin](/src/plugin
Another way is to trigger errors with the [error plugin](/src/plugins/error):

```sh
kdb setmeta /tests/tutorial/spec/should_not_be_here trigger/error C04200
kdb setmeta /tests/tutorial/spec/should_not_be_here trigger/error C03200
#> Using keyname spec/tests/tutorial/spec/should_not_be_here
kdb spec-mount /tests/tutorial
kdb set /tests/tutorial/spec/should_not_be_here abc
# STDOUT-REGEX: Using name (user|system)/tests/tutorial/spec/should_not_be_here
# RET: 5
# ERROR:C04200
# ERROR:C03200
kdb get /tests/tutorial/spec/should_not_be_here
# RET: 11
# STDERR: Did not find key '/tests/tutorial/spec/should_not_be_here'
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 @@ -77,7 +77,7 @@ class Delegator
{
#ifdef KDBERRORS_H
// TODO: Correct?
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (errorKey, "Could not create C++ plugin: %s", msg);
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (errorKey, "Could not create C++ plugin: %s", msg);
#endif
return -1;
}
Expand Down
24 changes: 8 additions & 16 deletions src/error/specification
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ ignore:true
:It is for errors which are not relevant anymore
:an empty line will start the next error specification

number:C01100
description:Resource
macro:RESOURCE

number:C01110
description:Out of Memory
macro:OUT_OF_MEMORY

number:C01120
description:General Resource
macro:GENERAL_RESOURCE

number:C01300
description:Installation
macro:INSTALLATION
Expand All @@ -32,25 +32,17 @@ description:Interface
macro:INTERFACE

number:C01430
description:Broken plugin
macro:BROKEN_PLUGIN
description:Plugin Misbehavior
macro:PLUGIN_MISBHV

number:C02000
description:Conflict
macro:CONFLICTING_STATE

number:C03000
description:Timeout
macro:TIMEOUT

number:C04100
number:C03100
description:Validation Syntactic
macro:VALIDATION_SYNTACTIC

number:C04200
number:C03200
description:Validation Semantic
macro:VALIDATION_SEMANTIC

number:C05000
description:Out of Range
macro:OUT_OF_RANGE
10 changes: 5 additions & 5 deletions src/include/kdbmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
do \
{ \
if (errno == EACCES) \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( \
ELEKTRA_SET_RESOURCE_ERRORF ( \
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_GENERAL_RESOURCE_ERRORF (parentKey, "Could not open configuration file for reading. Reason: %s", \
ELEKTRA_SET_RESOURCE_ERRORF (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_GENERAL_RESOURCE_ERRORF ( \
ELEKTRA_SET_RESOURCE_ERRORF ( \
parentKey, \
"Insufficient permissions to open configuration file for writing. You might want to retry as " \
"root. Errno: %s", \
strerror (errno)); \
else \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, ":Could not open file for writing %s", strerror (errno)); \
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, ":Could not open file for writing %s", strerror (errno)); \
} while (0)

#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (key, "Unable to allocate %zu bytes.", size);
#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_RESOURCE_ERRORF (key, "Unable to allocate %zu bytes.", size);

/**
* @brief Sets error if info != returned
Expand Down
6 changes: 3 additions & 3 deletions src/libs/elektra/kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int kdbClose (KDB * handle, Key * errorKey)
}
else
{
ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (errorKey, "Could not close modules: modules were not open");
ELEKTRA_ADD_RESOURCE_WARNING (errorKey, "Could not close modules: modules were not open");
}

if (handle->global) ksDel (handle->global);
Expand Down Expand Up @@ -1077,7 +1077,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey)

if (splitGet (split, parentKey, handle) == -1)
{
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks)));
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks)));
// continue, because sizes are already updated
}
ksClear (ks);
Expand Down Expand Up @@ -1112,7 +1112,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey)
/* Now post-process the updated keysets */
if (splitGet (split, parentKey, handle) == -1)
{
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks)));
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (parentKey, "Wrong keys in postprocessing: %s", keyName (ksCurrent (ks)));
// continue, because sizes are already updated
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/elektra/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config
{
if ((handle->kdbOpen (handle, errorKey)) == -1)
{
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (
errorKey,
"Open of plugin returned unsuccessfully: %s. Reason contains plugin, see other warnings for details", name);
elektraPluginClose (handle, errorKey);
Expand Down Expand Up @@ -328,7 +328,7 @@ int elektraPluginClose (Plugin * handle, Key * errorKey)
if (handle->kdbClose)
{
rc = handle->kdbClose (handle, errorKey);
if (rc == -1) ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (errorKey, "kdbClose() failed");
if (rc == -1) ELEKTRA_ADD_RESOURCE_WARNING (errorKey, "kdbClose() failed");
}

ksDel (handle->config);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/loader/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey)
}
ret = -1;
// TODO: Correct?
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (errorKey, "Could not close a module, dlclose failed: %s", dlerror ());
ELEKTRA_ADD_RESOURCE_WARNINGF (errorKey, "Could not close a module, dlclose failed: %s", dlerror ());

ksAppendKey (newModules, cur);
}
Expand Down
8 changes: 4 additions & 4 deletions src/libs/pluginprocess/pluginprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void elektraPluginProcessStart (Plugin * handle, ElektraPluginProcess * pp)
else
{
ELEKTRA_LOG_DEBUG ("Child: Unrecognized command %s", keyString (commandKey));
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (key, "Received invalid command code or no KeySet: %s", keyString (commandKey));
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (key, "Received invalid command code or no KeySet: %s", keyString (commandKey));
}
errno = prevErrno;
char * resultStr = longToStr (result);
Expand Down Expand Up @@ -329,7 +329,7 @@ int elektraPluginProcessSend (const ElektraPluginProcess * pp, pluginprocess_t c
long lresult = strtol (keyString (resultKey), &endPtr, 10);
if (*endPtr != '\0' || errno == ERANGE || lresult > INT_MAX || lresult < INT_MIN)
{
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (key, "Received invalid return code or no KeySet: %s", keyString (resultKey));
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (key, "Received invalid return code or no KeySet: %s", keyString (resultKey));
lresult = ELEKTRA_PLUGIN_STATUS_ERROR;
}
else // Copy everything back into the actual keysets
Expand Down Expand Up @@ -405,7 +405,7 @@ static int makePipe (ElektraPluginProcess * pp, Key * errorKey, const char * pip
if ((ret = pipe (pipeRef)))
{
cleanupPluginData (pp, errorKey, 1);
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret);
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (errorKey, "Failed to initialize %s, pipe () returned %d", pipeName, ret);
return 0;
}
return 1;
Expand Down Expand Up @@ -496,7 +496,7 @@ ElektraPluginProcess * elektraPluginProcessInit (Key * errorKey)
if (pp->pid < 0)
{
cleanupPluginData (pp, errorKey, 1);
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (errorKey, "Failed to fork the plugin process, fork () returned %d", pp->pid);
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (errorKey, "Failed to fork the plugin process, fork () returned %d", pp->pid);
return NULL;
}

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/augeas/augeas.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath,

memoryerror:
elektraFree (keyArray);
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree");
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree");
return -1;
}

Expand Down Expand Up @@ -494,7 +494,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey)
if (content == 0)
{
fclose (fh);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
}

/* convert the string into an augeas tree */
Expand Down Expand Up @@ -578,7 +578,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey)
if (content == 0)
{
fclose (fh);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
}

/* convert the string into an augeas tree */
Expand All @@ -605,7 +605,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey)
ret = saveFile (augeasHandle, fh);
fclose (fh);

if (ret < 0) ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Could not open file for writing: %s", strerror (errno));
if (ret < 0) ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file for writing: %s", strerror (errno));

errno = errnosave;
return 1;
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/blockresolver/blockresolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
struct stat buf;
if (stat (data->realFile, &buf))
{
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
return -1;
}
if (buf.st_mtime == data->mtime) return 0;
Expand All @@ -264,7 +264,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fin = fopen (data->realFile, "r");
if (!fin)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
goto GET_CLEANUP;
}

Expand All @@ -289,7 +289,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fout = fopen (data->tmpFile, "w");
if (!fout)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile);
retVal = -1;
goto GET_CLEANUP;
}
Expand All @@ -312,7 +312,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
struct stat buf;
if (stat (data->realFile, &buf))
{
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
return -1;
}
if (buf.st_mtime > data->mtime)
Expand All @@ -337,13 +337,13 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fout = fopen (mergeFile, "w");
if (!fout)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile);
goto SET_CLEANUP;
}
fin = fopen (data->realFile, "r");
if (!fin)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
goto SET_CLEANUP;
}
block = (char *) getBlock (fin, 0, data->startPos);
Expand All @@ -367,7 +367,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fin = fopen (data->tmpFile, "r");
if (!fin)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile);
goto SET_CLEANUP;
}
char buffer[BUFSIZE_MAX];
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int resolveCacheDirectory (Plugin * handle, CacheHandle * ch, Key * error
ch->resolver = elektraPluginOpen (KDB_RESOLVER, ch->modules, resolverConfig, ch->cachePath);
if (!ch->resolver)
{
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (errorKey, "Open of plugin returned unsuccessfully: %s", KDB_RESOLVER);
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (errorKey, "Open of plugin returned unsuccessfully: %s", KDB_RESOLVER);
elektraModulesClose (ch->modules, 0);
ksDel (ch->modules);
keyDel (ch->cachePath);
Expand All @@ -66,7 +66,7 @@ static int loadCacheStoragePlugin (Plugin * handle, CacheHandle * ch, Key * erro
ch->cacheStorage = elektraPluginOpen (KDB_CACHE_STORAGE, ch->modules, mmapstorageConfig, ch->cachePath);
if (!ch->cacheStorage)
{
ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF (errorKey, "Open of plugin returned unsuccessfully: %s", KDB_CACHE_STORAGE);
ELEKTRA_ADD_PLUGIN_MISBHV_WARNINGF (errorKey, "Open of plugin returned unsuccessfully: %s", KDB_CACHE_STORAGE);
elektraPluginClose (ch->resolver, 0);
elektraModulesClose (ch->modules, 0);
ksDel (ch->modules);
Expand Down Expand Up @@ -323,7 +323,7 @@ int elektraCacheSet (Plugin * handle, KeySet * returned, Key * parentKey)
{
if (rename (tmpFile, cacheFileName) == -1)
{
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Could not rename file. Errno: %s", strerror (errno));
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not rename file. Errno: %s", strerror (errno));
goto error;
}

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/conditionals/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ kdb setmeta user/tests/conditionals/key check/condition "(../hkey == 'hello') ?
# will fail
kdb setmeta user/tests/conditionals/key check/condition "(../hkey == 'hello') ? (../fkey == '5.0')"
# RET:5
# ERROR:C04200
# ERROR:C03200
```

Assignment example:
Expand Down Expand Up @@ -123,8 +123,8 @@ kdb export /tests/conditionals ini
#> sub/key=false
#> #@META check/condition = (./ == 'val1') ? (../sub/key == 'true')
#> key1=val1
# ERROR:C04200
# Sorry, module conditionals issued the error C04200:
# ERROR:C03200
# Sorry, module conditionals issued the error C03200:
# Validation failed: Validation of Key key1: (./ == 'val1') ? (../sub/key == 'true') failed. ((../sub/key == 'true') failed)

kdb set /tests/conditionals/sub/key true
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cpptemplate/cpptemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int elektraCppTemplateOpen (Plugin * handle, Key * key)
}
catch (exception const & error)
{
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (key, "Uncaught Exception: %s", error.what ());
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (key, "Uncaught Exception: %s", error.what ());
}

return status;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cpptype/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ kdb get user/tests/cpptype/key
# If we try to store a string Elektra will not change the value
kdb set user/tests/cpptype/key 'Not a char'
# STDERR: .*The type char failed to match.*
# ERROR: C04200
# ERROR: C03200
# RET: 5
kdb get user/tests/cpptype/key
#> b
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/crypto/botan_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int elektraCryptoBotanInit (Key * errorKey)
}
catch (std::exception const & e)
{
ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (errorKey, "Botan initialization failed: %s", e.what ());
ELEKTRA_SET_PLUGIN_MISBHV_ERRORF (errorKey, "Botan initialization failed: %s", e.what ());
return -1; // failure
}
return 1; // success
Expand Down
Loading

0 comments on commit 0101329

Please sign in to comment.