2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[65-libyang-generic] Better error report

This commit is contained in:
Francis Dupont
2018-09-03 17:41:09 +02:00
parent eb0e6b5756
commit 7b4a1604e4

View File

@@ -143,7 +143,8 @@ TranslatorBasic::value(ConstElementPtr elem, sr_type_t type) {
case SR_LIST_T: case SR_LIST_T:
if (elem->getType() != Element::list) { 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. // Return null.
break; break;
@@ -152,63 +153,81 @@ TranslatorBasic::value(ConstElementPtr elem, sr_type_t type) {
case SR_IDENTITYREF_T: case SR_IDENTITYREF_T:
case SR_ENUM_T: case SR_ENUM_T:
if (elem->getType() != Element::string) { 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)); s_val.reset(new Val(elem->stringValue().c_str(), type));
break; break;
case SR_BOOL_T: case SR_BOOL_T:
if (elem->getType() != Element::boolean) { 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)); s_val.reset(new Val(elem->boolValue(), type));
break; break;
case SR_UINT8_T: case SR_UINT8_T:
if (elem->getType() != Element::integer) { 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<uint8_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<uint8_t>(elem->intValue()), type));
break; break;
case SR_UINT16_T: case SR_UINT16_T:
if (elem->getType() != Element::integer) { 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<uint16_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<uint16_t>(elem->intValue()), type));
break; break;
case SR_UINT32_T: case SR_UINT32_T:
if (elem->getType() != Element::integer) { 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<uint32_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<uint32_t>(elem->intValue()), type));
break; break;
case SR_INT8_T: case SR_INT8_T:
if (elem->getType() != Element::integer) { 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<int8_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<int8_t>(elem->intValue()), type));
break; break;
case SR_INT16_T: case SR_INT16_T:
if (elem->getType() != Element::integer) { 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<int16_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<int16_t>(elem->intValue()), type));
break; break;
case SR_INT32_T: case SR_INT32_T:
if (elem->getType() != Element::integer) { 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<int32_t>(elem->intValue()), type)); s_val.reset(new Val(static_cast<int32_t>(elem->intValue()), type));
break; break;
case SR_BINARY_T: case SR_BINARY_T:
if (elem->getType() != Element::string) { 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)); s_val.reset(new Val(encode64(elem->stringValue()).c_str(), type));
break; break;