Parcourir la source

Merge branch 'gestion-erreur'

Sniperovitch il y a 8 ans
Parent
commit
38adf6b034
6 fichiers modifiés avec 26 ajouts et 9 suppressions
  1. 1 0
      .gitignore
  2. 0 0
      apache_config.txt
  3. 0 4
      config.yml
  4. 5 0
      config.yml.smp
  5. 5 5
      lib/Bartender.pm
  6. 15 0
      views/error.tt

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+config.yml

config_apache.txt → apache_config.txt


+ 0 - 4
config.yml

@@ -1,4 +0,0 @@
-cocktail:
-  binary: /home/sniperovitch/cocktail/cocktail
-  store: /tmp/exegetes
-

+ 5 - 0
config.yml.smp

@@ -0,0 +1,5 @@
+cocktail:
+  binary: /home/bernard/cocktail/cocktail
+  store: /tmp/bernard
+
+template: "simple"

+ 5 - 5
lib/Bartender.pm

@@ -12,14 +12,14 @@ get '/shake' => sub {
     my $opt_base   = $param{projetPadPrincipal};
     my $opt_garde  = $param{projetPadGarde};
     my $opt_projet = $param{projetId};
-    my $cocktail = config->{cocktail}{binary};
+    my $cocktail   = config->{cocktail}{binary};
     if(not defined $cocktail) {
-        warn "cocktail:binary n'est pas configuré dans config.yml";
-        return;
+        my $error->{message} = qq{"cocktail:binary" n'est pas configuré dans config.yml};
+        return template 'error', $error;
     }
     elsif(not -x $cocktail) {
-        warn "cocktail$cocktail n'est pas executable";
-        return;
+        my $error->{message} = qq{cocktail: "$cocktail" n'est pas executable};
+        return 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>