LibreCat / Catmandu

Catmandu - a data processing toolkit
https://librecat.org
176 stars 31 forks source link

Error reporting in Catmandu::Exporter::Template #4

Closed pietsch closed 11 years ago

pietsch commented 11 years ago

The Programmers Guide tutorial contains a section showing basic usage of the TT2-based exporter. When trying out the following code snippet, it took me a long time to figure out why no output was produced:

use Catmandu::Exporter::Template;
my $data     = [
 { name => { first => 'James' , last => 'Bond' } , occupation => 'Secret Agent' } ,
 { name => { first => 'Ernst' , last => 'Blofeld' } , occupation => 'Supervillain' } ,
];
my $exporter = Catmandu::Exporter::Template->new(template => '/home/phochste/example.tt');
$exporter->add_many($data);

Of course, I am not phochste, so I changed the path to the template file into "example.tt", expecting the exporter to read the template from the current directory. That was a mistake. This value must be a full, absolute path, and no tilde (~) expansion is performed.

Perhaps this module should make more of an effort to find the template file. In any case, some kind of error message, warning or exception should be produced when the template file cannot be found.

nics commented 11 years ago

fixed by 80a3cb1904107aad12833f8a0f8cf3d794c46fdf