CrashTest.pl
changeset 34 e0d6597078a5
parent 32 3e776f1b21d4
child 37 013953be0f3b
--- a/CrashTest.pl	Mon Aug 04 15:45:02 2014 +0200
+++ b/CrashTest.pl	Thu Aug 07 23:50:08 2014 +0200
@@ -27,14 +27,30 @@
 
 app->attr(storage => sub {
     my $self = shift;
-    eval "require $config->{Storage}->{Type}" or die "Loading module failed $@";
-    return $config->{Storage}->{Type}->new($config->{Storage});
+    my $loader = Mojo::Loader->new;
+
+    my $storage_class = $self->app->config->{Storage}->{Type};
+    if (my $e = $loader->load($storage_class)) {
+        die ref $e ? "Exception: $e" : 'Not found!';
+    }
+
+    return $storage_class->new(config => $self->app->config->{Storage});
 });
 
 app->attr(decode_queue => sub {
     my $self = shift;
-    eval "require $config->{DecodeQueue}->{Type}" or die "Loading module failed $@";
-    return $config->{DecodeQueue}->{Type}->new($config->{DecodeQueue}, $config->{Dumper}, app->storage);
+    my $loader = Mojo::Loader->new;
+
+    my $decode_class = $self->app->config->{DecodeQueue}->{Type};
+    if (my $e = $loader->load($decode_class)) {
+        die ref $e ? "Exception: $e" : 'Not found!';
+    }
+
+    return $decode_class->new(
+        config => $self->app->config->{DecodeQueue},
+        dumper_config => $self->app->config->{Dumper},
+        storage => $self->app->storage
+    );
 });
 
 helper scm_file_link => sub {