Skip to content

Instantly share code, notes, and snippets.

/load.diff Secret

Created July 5, 2015 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2a1bd699f84c83a70173 to your computer and use it in GitHub Desktop.
Save anonymous/2a1bd699f84c83a70173 to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/Server.pm b/lib/Mojo/Server.pm
index 58c9513..43c6d9e 100644
--- a/lib/Mojo/Server.pm
+++ b/lib/Mojo/Server.pm
@@ -50,8 +50,8 @@ 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($@ || $!);';
+ my $app
+ = eval "package Mojo::Server::Sandbox::@{[md5_sum $path]}; do(\$path)";
die qq{Can't load application from file "$path": $@} if !$app && $@;
die qq{File "$path" did not return an application object.\n}
unless blessed $app && $app->isa('Mojo');
diff --git a/t/mojo/daemon.t b/t/mojo/daemon.t
index c32f7ca..52d717c 100644
--- a/t/mojo/daemon.t
+++ b/t/mojo/daemon.t
@@ -89,7 +89,7 @@ eval {
Mojo::Server::Daemon->new->load_app(
"$FindBin::Bin/lib/Mojo/LoaderException.pm");
};
-like $@, qr/^Can't load application/, 'right error';
+like $@, qr/did not return an application object/, 'right error';
# Load missing application class
eval { Mojo::Server::Daemon->new->build_app('Mojo::DoesNotExist') };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment