diff options
Diffstat (limited to 'crashboxd/src/main/scala/io/crashbox/ci/yaml/YamlReader.scala')
-rw-r--r-- | crashboxd/src/main/scala/io/crashbox/ci/yaml/YamlReader.scala | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crashboxd/src/main/scala/io/crashbox/ci/yaml/YamlReader.scala b/crashboxd/src/main/scala/io/crashbox/ci/yaml/YamlReader.scala new file mode 100644 index 0000000..f486676 --- /dev/null +++ b/crashboxd/src/main/scala/io/crashbox/ci/yaml/YamlReader.scala @@ -0,0 +1,24 @@ +package io.crashbox.ci +package yaml + +trait YamlReader[A] { + + def read(yml: YamlValue): A + + protected def formatError(found: YamlValue, required: String) = { + val foundType = found match { + case _: YamlString => "string" + case _: YamlSeq => "sequence" + case _: YamlMap => "mapping" + } + + throw new YamlFormatException( + s"$found is of type $foundType, required: $required" + ) + } + + protected def readError(node: YamlValue, msg: String) = { + throw new YamlFormatException(node.toString + ": " + msg) + } + +} |