Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use a different idiom for application loading
  • Loading branch information
kraih committed Jul 5, 2015
1 parent f43208c commit be44060
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

6.13 2015-07-03
6.13 2015-07-05
- Improved error messages for broken applications in Mojo::Server. (mst)
- Improved subscribers method in Mojo::EventEmitter to allow subscribers to be
modified more easily.

Expand Down
7 changes: 4 additions & 3 deletions lib/Mojo/Server.pm
Expand Up @@ -50,9 +50,10 @@ sub load_app {
local $ENV{MOJO_EXE};

# Try to load application from script into sandbox
my $app = eval "package Mojo::Server::Sandbox::@{[md5_sum $path]};"
. 'return do($path) || die($@ || $!);';
die qq{Can't load application from file "$path": $@} if !$app && $@;
delete $INC{$path};
my $app = eval
"package Mojo::Server::Sandbox::@{[md5_sum $path]}; require \$path";
die qq{Can't load application from file "$path": $@} if $@;
die qq{File "$path" did not return an application object.\n}
unless blessed $app && $app->isa('Mojo');
$self->app($app);
Expand Down
2 changes: 2 additions & 0 deletions lib/Mojolicious.pm
Expand Up @@ -916,6 +916,8 @@ Mark Stosberg
Marty Tennison
Matt S Trout
Matthew Lineen
Maksym Komar
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/Config.pm
Expand Up @@ -17,7 +17,7 @@ sub parse {
my $config
= eval 'package Mojolicious::Plugin::Config::Sandbox; no warnings;'
. "sub app; local *app = sub { \$app }; use Mojo::Base -strict; $content";
die qq{Can't load configuration from file "$file": $@} if !$config && $@;
die qq{Can't load configuration from file "$file": $@} if $@;
die qq{Configuration file "$file" did not return a hash reference.\n}
unless ref $config eq 'HASH';

Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/JSONConfig.pm
Expand Up @@ -8,7 +8,7 @@ sub parse {
my ($self, $content, $file, $conf, $app) = @_;

my $config = eval { from_json $self->render($content, $file, $conf, $app) };
die qq{Can't parse config "$file": $@} if !$config && $@;
die qq{Can't parse config "$file": $@} if $@;
die qq{Invalid config "$file"} unless ref $config eq 'HASH';

return $config;
Expand Down

0 comments on commit be44060

Please sign in to comment.