Changeset 907


Ignore:
Timestamp:
Dec 10, 2006, 9:22:38 PM (15 years ago)
Author:
Earle Martin
Message:

Report Config::Tiny errors - closes #109. Now croaks if specified config file can't be read.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/Config.pm

    r894 r907  
    22use strict;
    33
     4use Carp qw( croak );
    45use Config::Tiny;
    56
     
    103104    if ( $args{file} ) {
    104105        my $read_config = Config::Tiny->read( $args{file} ) or
    105             warn "Cannot read config file $args{file}";
    106         %stored = $read_config ? %{ $read_config->{_} } : ();
     106            croak "Cannot read config file '$args{file}': " . $Config::Tiny::errstr;
     107        %stored = $read_config->{_};
    107108    } elsif ( $args{vars} ) {
    108109        %stored = %{ $args{vars} };
     
    158159        http_charset => "What character set should we put in the http headers? (This won't change the character set internally, just what it's reported as). Leave blank for none to be sent",
    159160        formatting_rules_node => "What's the name of the node or page to use for the text formatting rules link (this is by default an external document, but if you make formatting_rules_link empty, it will be a wiki node instead",
    160         formatting_rules_link => "What URL do you want to use for the text formatting rules (leave blank to use a wiki node instead)?",
     161        formatting_rules_link => "What URL do you want to use for the text formatting rules (leave blank to use a wiki node instead)?",
    161162        backlinks_in_title => "Make node titles link to node backlinks (C2 style)?",
    162163        ellipsoid => "Which ellipsoid do you want to use? (eg 'Airy', 'WGS-84')",
  • trunk/t/11_utils.t

    r804 r907  
    33use OpenGuides::Config;
    44use OpenGuides::Utils;
    5 use Test::More tests => 7;
     5use Test::More tests => 8;
    66
    77eval { my $wiki = OpenGuides::Utils->make_wiki_object; };
     
    1010eval { my $wiki = OpenGuides::Utils->make_wiki_object( config => "foo" ); };
    1111ok( $@, "...and if config param isn't an OpenGuides::Config object" );
     12
     13eval {
     14    my $wiki = OpenGuides::Utils->make_wiki_object(
     15        config => OpenGuides::Config->new( file => 'fake' )
     16    );
     17};
     18
     19like( $@, qr/File 'fake' does not exist/, '...and Config::Tiny errors are reported');
    1220
    1321eval { require DBD::SQLite; };
Note: See TracChangeset for help on using the changeset viewer.