From c4b8fccb8231450fbcd9caa0dddd81906c774341 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 13 Feb 2015 17:14:07 +0100 Subject: [PATCH] Error if the database isn't available Instead of failing silently later --- lib/Vroom/I18N/en.pm | 1 + lib/Vroom/I18N/fr.pm | 3 ++- vroom.pl | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/Vroom/I18N/en.pm b/lib/Vroom/I18N/en.pm index 72544f8..076148e 100644 --- a/lib/Vroom/I18N/en.pm +++ b/lib/Vroom/I18N/en.pm @@ -15,6 +15,7 @@ our %Lexicon = ( "ERROR_ROOM_s_LOCKED" => "The room %s is locked, you cannot join it", "ERROR_OCCURRED" => "An error occurred", "ERROR_NOT_LOGGED_IN" => "Sorry, your not logged in", + "ERROR_DB_UNAVAILABLE" => "The database is not available", "JS_REQUIRED" => "VROOM needs javascript to work properly", "EMAIL_INVITATION" => "Video conference invitation", "INVITE_SENT_TO_s" => "An invitation was sent to the following addresses\n%s", diff --git a/lib/Vroom/I18N/fr.pm b/lib/Vroom/I18N/fr.pm index 3b8cf04..e383ed3 100644 --- a/lib/Vroom/I18N/fr.pm +++ b/lib/Vroom/I18N/fr.pm @@ -16,7 +16,8 @@ our %Lexicon = ( "ERROR_ROOM_s_DOESNT_EXIST" => "Le salon %s n'existe pas", "ERROR_ROOM_s_LOCKED" => "Le salon %s est verrouillé, vous ne pouvez pas le rejoindre", "ERROR_OCCURRED" => "Une erreur est survenue", - "ERROR_NOT_LOGGED_IN" => "Désolé, vous n'êtes pas identifié", + "ERROR_NOT_LOGGED_IN" => "Désolé, vous n'êtes pas identifié",, + "ERROR_DB_UNAVAILABLE" => "La base de données n'est pas accessible", "JS_REQUIRED" => "VROOM nécessite l'activation du javascript", "EMAIL_INVITATION" => "Invitation à une conférence vidéo", "YOU_ARE_INVITED_TO_A_MEETING" => "Vous êtes attendu sur un salon de vidéo conférence. " . diff --git a/vroom.pl b/vroom.pl index 3e34013..22609d8 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1892,6 +1892,15 @@ app->hook(before_dispatch => sub { } # Stash the configuration hashref $self->stash(config => $config); + + # Check db is available + if (!$self->db){ + $self->app->log->info("Connect connect to the database"); + return $self->render('error', + msg => $self->l('ERROR_DB_UNAVAILABLE'), + err => 'ERROR_DB_UNAVAILABLE' + ); + } }); # Are we running in hypnotoad ? app->config(