diff options
author | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-05-28 18:15:39 +0200 |
---|---|---|
committer | Jonathan Aillet <jonathan.aillet@iot.bzh> | 2019-06-04 13:13:47 +0000 |
commit | 0749697635678cbbe48bdf74e8be3e926e5b7d69 (patch) | |
tree | 411edea53d32e854e4abd422a82d7ae544ef1bb2 /ctl-lib | |
parent | a13401e9b5393edf65cd1ca8c11491926b5568ff (diff) |
Add prints when calling section callbackshalibut_7.99.2halibut/7.99.27.99.2
Add error/warning prints when calling controller section callbacks.
Move to next section if no callback is registered.
Also, at section callback calls, return an error directly when
the error is caught.
Bug-AGL: SPEC-2469
Change-Id: I5808087d55b77d22a3878fd60015bc09063ac717
Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r-- | ctl-lib/ctl-config.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c index ef6038b..28d493e 100644 --- a/ctl-lib/ctl-config.c +++ b/ctl-lib/ctl-config.c @@ -153,15 +153,24 @@ int CtlConfigExec(afb_api_t apiHandle, CtlConfigT *ctlConfig) { #endif // Loop on every section and process config - int errcount=0; + int error; for (int idx = 0; ctlConfig->sections[idx].key != NULL; idx++) { - if (!ctlConfig->sections[idx].loadCB) - AFB_API_NOTICE(apiHandle, "CtlConfigLoad: notice empty section '%s'", ctlConfig->sections[idx].key); - else - errcount += ctlConfig->sections[idx].loadCB(apiHandle, &ctlConfig->sections[idx], NULL); + if (!ctlConfig->sections[idx].loadCB) { + AFB_API_NOTICE(apiHandle, "Notice empty section '%s'", ctlConfig->sections[idx].key); + continue; + } + + error = ctlConfig->sections[idx].loadCB(apiHandle, &ctlConfig->sections[idx], NULL); + if (error < 0) { + AFB_API_ERROR(apiHandle, "Error %i caught during call to '%s' section callback", error, ctlConfig->sections[idx].key); + return -idx; + } + else if (error > 0) { + AFB_API_WARNING(apiHandle, "Warning %i raised during call to '%s' section callback", error, ctlConfig->sections[idx].key); + } } - return errcount; + return 0; } CtlConfigT *CtlLoadMetaDataJson(afb_api_t apiHandle, json_object *ctlConfigJ, const char *prefix) { |