Browse Source

gestion d'erreur

Sniperovitch 8 years ago
parent
commit
857dfe7abb
2 changed files with 19 additions and 4 deletions
  1. 4 4
      lib/Bartender.pm
  2. 15 0
      views/error.tt

+ 4 - 4
lib/Bartender.pm

@@ -14,12 +14,12 @@ get '/shake' => sub {
     my $opt_projet = $param{projetId};
     my $cocktail = config->{cocktail}{binary};
     if(not defined $cocktail) {
-        warn "cocktail:binary n'est pas configuré dans config.yml";
-        return;
+        my $error->{message} = "cocktail:binary n'est pas configuré dans config.yml";
+        template 'error', $error;
     }
     elsif(not -x $cocktail) {
-        warn "cocktail$cocktail n'est pas executable";
-        return;
+        my $error->{message} = "cocktail$cocktail n'est pas executable";
+        template 'error', $error;
     }
     system("$cocktail -d $opt_dossier -b '$opt_base' -g '$opt_garde' -p $opt_projet &");
     redirect request->referer;

+ 15 - 0
views/error.tt

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html lang="fr">
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
+    <title>Erreur</title>
+    <link rel="stylesheet" href="/error.css">
+  </head>
+  <body>
+    <h1>Erreur</h1>
+    <div id="content">
+      <p>Erreur : [% error.message %]</p>
+    </div>
+  </body>
+</html>