fix error loading bad file
This commit is contained in:
parent
efe4a48d8f
commit
ca6a46421d
|
@ -81,10 +81,12 @@ public class Pluie.Yaml.Config
|
||||||
this.display_file = display_file;
|
this.display_file = display_file;
|
||||||
if (this.path != null) {
|
if (this.path != null) {
|
||||||
this.loader = new Yaml.Loader (this.path, display_file, false);
|
this.loader = new Yaml.Loader (this.path, display_file, false);
|
||||||
Yaml.Node? root = this.loader.get_nodes ();
|
if (this.loader.done) {
|
||||||
if (root != null) {
|
Yaml.Node? root = this.loader.get_nodes ();
|
||||||
this.finder = new Yaml.Finder(root);
|
if (root != null) {
|
||||||
this.get_imports ();
|
this.finder = new Yaml.Finder(root);
|
||||||
|
this.get_imports ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,9 +107,9 @@ public class Pluie.Yaml.Config
|
||||||
/**
|
/**
|
||||||
* retriew the corresponding Yaml.Root node for loaded yaml file
|
* retriew the corresponding Yaml.Root node for loaded yaml file
|
||||||
*/
|
*/
|
||||||
public Yaml.Root root_node ()
|
public Yaml.Root? root_node ()
|
||||||
{
|
{
|
||||||
return this.finder.context as Yaml.Root;
|
return this.finder!=null ? this.finder.context as Yaml.Root : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,20 +61,22 @@ public class Pluie.Yaml.Loader
|
||||||
public Loader (string path, bool display_file = false, bool displayNode = false )
|
public Loader (string path, bool display_file = false, bool displayNode = false )
|
||||||
{
|
{
|
||||||
this.reader = new Io.Reader (path);
|
this.reader = new Io.Reader (path);
|
||||||
this.scanner = new Yaml.Scanner (path);
|
if (this.reader.readable) {
|
||||||
if (display_file) this.display_file ();
|
this.scanner = new Yaml.Scanner (path);
|
||||||
|
if (display_file) this.display_file ();
|
||||||
|
|
||||||
if ((this.done = this.scanner.run())) {
|
if ((this.done = this.scanner.run())) {
|
||||||
if (displayNode) {
|
if (displayNode) {
|
||||||
var n = this.get_nodes ();
|
var n = this.get_nodes ();
|
||||||
if (n != null) n.display_childs ();
|
if (n != null) n.display_childs ();
|
||||||
of.state(n != null);
|
of.state(n != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var evt = this.scanner.get_error_event ();
|
||||||
|
of.error ("line %d (%s)".printf (evt.line, evt.data["error"]));
|
||||||
|
this.display_file (evt.line);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
var evt = this.scanner.get_error_event ();
|
|
||||||
of.error ("line %d (%s)".printf (evt.line, evt.data["error"]));
|
|
||||||
this.display_file (evt.line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user