Display exceptions when loading Mojo DB drivers
authorVincent Tondellier <tonton+hg@team1664.org>
Sat, 12 Dec 2015 15:56:51 +0100
changeset 80 d33b5f6e0862
parent 79 4ae8bb6f8a96
child 81 29e378724e62
Display exceptions when loading Mojo DB drivers
lib/CrashTest/Plugin/Storage/Sql.pm
--- a/lib/CrashTest/Plugin/Storage/Sql.pm	Sat Dec 12 15:55:55 2015 +0100
+++ b/lib/CrashTest/Plugin/Storage/Sql.pm	Sat Dec 12 15:56:51 2015 +0100
@@ -37,7 +37,10 @@
     my $self = shift;
 
     my $type = $self->dbtype;
-    load_class "Mojo::$type";
+    # Handle exceptions
+    if(my $e = load_class "Mojo::$type") {
+        die ref $e ? "Exception: $e" : "Mojo::$type is not installed";
+    }
     state $dbh = "Mojo::$type"->new($self->config->{db}->{$type});
 };