[Asterisk-code-review] main/sorcery: Provide log messages when a wizard does not su... (asterisk[13])
Matt Jordan
asteriskteam at digium.com
Tue Jul 14 20:48:02 CDT 2015
Matt Jordan has submitted this change and it was merged.
Change subject: main/sorcery: Provide log messages when a wizard does not support an operation
......................................................................
main/sorcery: Provide log messages when a wizard does not support an operation
If a sorcery wizard does not support one of the 'optional' CRUD
operations (namely the CUD), log a WARNING message so we are aware of
why the operation failed. This also removes an assert in this case, as
the CUD operation may have been triggered by an external system, in
which case it is not a programming error but a configuration error.
Change-Id: Ifecd9df946d9deaa86235257b49c6e5e24423b53
---
M main/sorcery.c
1 file changed, 13 insertions(+), 5 deletions(-)
Approvals:
Anonymous Coward #1000019: Verified
Matt Jordan: Looks good to me, approved
diff --git a/main/sorcery.c b/main/sorcery.c
index 7a4a7f3..2f45196 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -1944,9 +1944,7 @@
const struct sorcery_details *details = arg;
if (!object_wizard->wizard->callbacks.create) {
- ast_assert(0);
- ast_log(LOG_ERROR, "Sorcery wizard '%s' doesn't contain a 'create' virtual function.\n",
- object_wizard->wizard->callbacks.name);
+ ast_debug(5, "Sorcery wizard '%s' does not support creation\n", object_wizard->wizard->callbacks.name);
return 0;
}
return (!object_wizard->caching && !object_wizard->wizard->callbacks.create(details->sorcery, object_wizard->data, details->obj)) ? CMP_MATCH | CMP_STOP : 0;
@@ -2039,7 +2037,12 @@
const struct ast_sorcery_object_wizard *object_wizard = obj;
const struct sorcery_details *details = arg;
- return (object_wizard->wizard->callbacks.update && !object_wizard->wizard->callbacks.update(details->sorcery, object_wizard->data, details->obj) &&
+ if (!object_wizard->wizard->callbacks.update) {
+ ast_debug(5, "Sorcery wizard '%s' does not support updating\n", object_wizard->wizard->callbacks.name);
+ return 0;
+ }
+
+ return (!object_wizard->wizard->callbacks.update(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}
@@ -2107,7 +2110,12 @@
const struct ast_sorcery_object_wizard *object_wizard = obj;
const struct sorcery_details *details = arg;
- return (object_wizard->wizard->callbacks.delete && !object_wizard->wizard->callbacks.delete(details->sorcery, object_wizard->data, details->obj) &&
+ if (!object_wizard->wizard->callbacks.delete) {
+ ast_debug(5, "Sorcery wizard '%s' does not support deletion\n", object_wizard->wizard->callbacks.name);
+ return 0;
+ }
+
+ return (!object_wizard->wizard->callbacks.delete(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}
--
To view, visit https://gerrit.asterisk.org/849
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifecd9df946d9deaa86235257b49c6e5e24423b53
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list