X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FHelper.pm;h=a717bee9d4c10325c8afce68a8b78b1e972f21dd;hb=fb9257c1ef523c89c4d5b8accd000809ded660e9;hp=32d28583d3cdaf899c5ec6f317ac75e528b02067;hpb=3d5bb03e9c02fb0b12f4c7a0eddedab4537e7be7;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Helper.pm b/lib/Catalyst/Helper.pm index 32d2858..a717bee 100644 --- a/lib/Catalyst/Helper.pm +++ b/lib/Catalyst/Helper.pm @@ -9,6 +9,7 @@ use IO::File; use FindBin; use Template; use Catalyst; +use Catalyst::Exception; my %cache; @@ -63,7 +64,7 @@ sub mk_app { $self->{appprefix} = lc $self->{dir}; $self->{appprefix} =~ s/-/_/g; $self->{startperl} = $Config{startperl}; - $self->{scriptgen} = $Catalyst::CATALYST_SCRIPT_GEN; + $self->{scriptgen} = $Catalyst::CATALYST_SCRIPT_GEN || 4; $self->{author} = $self->{author} = $ENV{'AUTHOR'} || eval { @{ [ getpwuid($<) ] }[6] } || 'Catalyst developer'; @@ -102,7 +103,13 @@ sub mk_component { my @args = @_; my $class = "Catalyst::Helper::$helper"; eval "require $class"; - die qq/Couldn't load helper "$class", "$@"/ if $@; + + if ( $@ ) { + Catalyst::Exception->throw( + message => qq/Couldn't load helper "$class", "$@"/ + ); + } + if ( $class->can('mk_stuff') ) { return 1 unless $class->mk_stuff( $self, @args ); } @@ -145,7 +152,13 @@ sub mk_component { $comp = 'Controller' if $type eq 'C'; my $class = "Catalyst::Helper::$comp\::$helper"; eval "require $class"; - die qq/Couldn't load helper "$class", "$@"/ if $@; + + if ( $@ ) { + Catalyst::Exception->throw( + message => qq/Couldn't load helper "$class", "$@"/ + ); + } + if ( $class->can('mk_compclass') ) { return 1 unless $class->mk_compclass( $self, @args ); } @@ -178,11 +191,14 @@ sub mk_dir { print qq/ exists "$dir"\n/; return 0; } - if ( mkpath $dir) { + if ( mkpath [$dir] ) { print qq/created "$dir"\n/; return 1; } - die qq/Couldn't create "$dir", "$!"/; + + Catalyst::Exception->throw( + message => qq/Couldn't create "$dir", "$!"/ + ); } =head3 mk_file @@ -202,7 +218,10 @@ sub mk_file { print qq/created "$file"\n/; return 1; } - die qq/Couldn't create "$file", "$!"/; + + Catalyst::Exception->throw( + message => qq/Couldn't create "$file", "$!"/ + ); } =head3 next_test @@ -220,7 +239,7 @@ sub next_test { $tname = $prefix . '.t'; $self->{prefix} = $prefix; $prefix = lc $prefix; - $prefix =~ s/-/\//g + $prefix =~ s/-/\//g; $self->{uri} = $prefix; } my $dir = $self->{test_dir};