summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-15 10:51:54 +0100
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-07-15 13:59:42 +0100
commiteb7dbd8ddcea4909bef92e70b2b63a06eff005a9 (patch)
tree42f56c8ee1c140933b8252700e8cc814c59ef32c
parentaa7ab1df2364524fcbc83ebc9786da76fd438980 (diff)
downloadbuildstream-eb7dbd8ddcea4909bef92e70b2b63a06eff005a9.tar.gz
node: Make error messages more user-friendly
Users should not have to know anything about nodes, and should be greeted by commonly defined yaml types.
-rw-r--r--src/buildstream/node.pyx16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/buildstream/node.pyx b/src/buildstream/node.pyx
index 5c4db051b..53cbc28d3 100644
--- a/src/buildstream/node.pyx
+++ b/src/buildstream/node.pyx
@@ -298,7 +298,7 @@ cdef class MappingNode(Node):
if type(value) is not MappingNode and value is not None:
provenance = value.get_provenance()
raise LoadError(LoadErrorReason.INVALID_DATA,
- "{}: Value of '{}' is not of the expected type 'Mapping'"
+ "{}: Value of '{}' is not of the expected type 'dict'"
.format(provenance, key))
return value
@@ -316,9 +316,17 @@ cdef class MappingNode(Node):
if allowed_types and type(value) not in allowed_types:
provenance = self.get_provenance()
+ human_types = []
+ if MappingNode in allowed_types:
+ human_types.append("dict")
+ if SequenceNode in allowed_types:
+ human_types.append('list')
+ if ScalarNode in allowed_types:
+ human_types.append('scalar')
+
raise LoadError(LoadErrorReason.INVALID_DATA,
"{}: Value of '{}' is not one of the following: {}.".format(
- provenance, key, ", ".join(allowed_types)))
+ provenance, key, ", ".join(human_types)))
return value
@@ -331,7 +339,7 @@ cdef class MappingNode(Node):
else:
provenance = value.get_provenance()
raise LoadError(LoadErrorReason.INVALID_DATA,
- "{}: Value of '{}' is not of the expected type 'Scalar'"
+ "{}: Value of '{}' is not of the expected type 'scalar'"
.format(provenance, key))
return value
@@ -342,7 +350,7 @@ cdef class MappingNode(Node):
if type(value) is not SequenceNode and value is not None:
provenance = value.get_provenance()
raise LoadError(LoadErrorReason.INVALID_DATA,
- "{}: Value of '{}' is not of the expected type 'Sequence'"
+ "{}: Value of '{}' is not of the expected type 'list'"
.format(provenance, key))
return value