MT#10071 print YAML::Tiny error message if failed to read yml file

Sometimes it contains very useful information, like:
> /usr/share/ngcp-ngcpcfg/helper//validate-yml /etc/ngcp-config/network.yml
>> YAML::Tiny failed to classify line '      hwaddr:5C:F3:FC:11:67:26 '
>> Can't call method "write_string" without a package or object
>> reference at /usr/share/ngcp-ngcpcfg/helper//validate-yml line 15.

Change-Id: I762b4dc1b0e6b3446f6a431b038fa6ed674e5516
changes/48/648/4
Alexander Lutay 12 years ago
parent 1bab9f97a7
commit c4a0658080

@ -10,7 +10,7 @@ use File::Temp qw/tempfile/;
my $yaml = YAML::Tiny->new;
my $inputfile = shift or die 'You did not specify an input file name';
my $outputfile = new File::Temp( UNLINK => 1 );
$yaml = YAML::Tiny->read($inputfile);
$yaml = YAML::Tiny->read($inputfile) || die "Could not read $inputfile\n".$yaml->errstr()."\n";
open(my $fh, '>', "$outputfile") or die "Could not open $outputfile for writing";
print $fh $yaml->write_string() or die "Could not write YAML to $outputfile";

Loading…
Cancel
Save