Skip to content

Document without title causes unhelpful error in template #435

@preaction

Description

@preaction

I created a document without a title, which is perfectly valid, but when I try to use that document in a template, I get the following error:

Error in template: Undef did not pass type constraint "Str" (in $self->{"title"}) at (eval 652) line 68
    "Str" is a subtype of "Value"
    "Value" is a subtype of "Defined"
    Undef did not pass type constraint "Defined" (in $self->{"title"})
    "Defined" is defined as: (defined($_))

Nowhere in the error message tells me where the problem is, what document I'm trying to write, or how I could possibly fix this.

Running under -vv verboseness gave me nothing useful:

[Sun Jan 24 01:57:49 2016] [debug] Write file: /blog/2015/04/26/chicken-broccoli-alfredo/making-sauce-2.jpg
[Sun Jan 24 01:57:49 2016] [debug] Write file: /blog/2015/04/12/cheddar-cheese-sauce/adding-cheese-3.jpg
[Sun Jan 24 01:57:49 2016] [debug] Write file: /blog/2015/04/05/banana-bread/add-sugar-2.jpg
[Sun Jan 24 01:57:49 2016] [debug] Write file: /blog/2015/04/05/the-mac-and-cheese-experiment---3---pre-made-sauces/add-velveeta-cheese-1.jpg
[Sun Jan 24 01:57:49 2016] [debug] Write file: /blog/2015/09/05/baked-sweet-and-sour-chicken/index.html
Error in template: Undef did not pass type constraint "Str" (in $self->{"title"}) at (eval 652) line 68
    "Str" is a subtype of "Value"
    "Value" is a subtype of "Defined"
    Undef did not pass type constraint "Defined" (in $self->{"title"})
    "Defined" is defined as: (defined($_))

Running under Carp::Always gives me more to go on:

Error in template: Undef did not pass type constraint "Str" (in $self->{"title"}) at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Statocles/Template.pm line 133.
        Statocles::Template::render(Statocles::Template=HASH(0x7ff5c3ee1b08), "content", "<h1>indiepalate.com</h1>\x{a}\x{a}<p>This is the source and files for"..., "app", Statocles::App::Basic=HASH(0x7ff5c6394b50), "doc", Statocles::Document=HASH(0x7ff5c3f9cdd0), "site", Statocles::Site=HASH(0x7ff5c3b94b30), ...) called at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Statocles/Page.pm line 177
        Statocles::Page::render(Statocles::Page::Document=HASH(0x7ff5c3f17510), "site", Statocles::Site=HASH(0x7ff5c3b94b30)) called at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Statocles/Site.pm line 291
        Statocles::Site::build(Statocles::Site=HASH(0x7ff5c3b94b30)) called at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Statocles/Site.pm line 359
        Statocles::Site::deploy(Statocles::Site=HASH(0x7ff5c3b94b30)) called at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/lib/site_perl/5.20.0/Statocles/Command.pm line 122
        Statocles::Command::main("Statocles::Command", "-vv", "deploy") called at /Users/doug/perl5/perlbrew/perls/perl-5.20.0/bin/statocles line 16

When there's an error in the template, we need to give enough information to solve the problem. We should also add "Rendering page: " as debug-level (-vv) output to try to help with these problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions