From: Francis Dupont Date: Mon, 3 Sep 2018 15:41:09 +0000 (+0200) Subject: [65-libyang-generic] Better error report X-Git-Tag: libyang-generic_to_be_rebased X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe8cb245d8ad1ec473f3eb83a891a92f2cb0c7af;p=thirdparty%2Fkea.git [65-libyang-generic] Better error report --- diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc index 6d4199af26..1613bba019 100644 --- a/src/lib/yang/translator.cc +++ b/src/lib/yang/translator.cc @@ -143,7 +143,8 @@ TranslatorBasic::value(ConstElementPtr elem, sr_type_t type) { case SR_LIST_T: if (elem->getType() != Element::list) { - isc_throw(BadValue, "value for a list called with not a list"); + isc_throw(BadValue, "value for a list called with not a list: " + << elem->str()); } // Return null. break; @@ -152,63 +153,81 @@ TranslatorBasic::value(ConstElementPtr elem, sr_type_t type) { case SR_IDENTITYREF_T: case SR_ENUM_T: if (elem->getType() != Element::string) { - isc_throw(BadValue, "value for a string called with not a string"); + isc_throw(BadValue, + "value for a string called with not a string: " + << elem->str()); } s_val.reset(new Val(elem->stringValue().c_str(), type)); break; case SR_BOOL_T: if (elem->getType() != Element::boolean) { - isc_throw(BadValue, "value for a boolean called with not a boolean"); + isc_throw(BadValue, + "value for a boolean called with not a boolean: " + << elem->str()); } s_val.reset(new Val(elem->boolValue(), type)); break; case SR_UINT8_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_UINT16_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_UINT32_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_INT8_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_INT16_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_INT32_T: if (elem->getType() != Element::integer) { - isc_throw(BadValue, "value for an integer called with not an integer"); + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); } s_val.reset(new Val(static_cast(elem->intValue()), type)); break; case SR_BINARY_T: if (elem->getType() != Element::string) { - isc_throw(BadValue, "value for a base64 called with not a string"); + isc_throw(BadValue, + "value for a base64 called with not a string: " + << elem->str()); } s_val.reset(new Val(encode64(elem->stringValue()).c_str(), type)); break;