Handle errors for invalid YAML. Fixes #298.