[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GT] SVN Commit r646 - trunk/GT
Author: joao
Date: 2008-07-13 20:05:45 +0200 (Sun, 13 Jul 2008)
New Revision: 646
Modified:
trunk/GT/Tools.pm
Log:
Additional validation of user input errors
Modified: trunk/GT/Tools.pm
===================================================================
--- trunk/GT/Tools.pm 2008-07-09 21:21:40 UTC (rev 645)
+++ trunk/GT/Tools.pm 2008-07-13 18:05:45 UTC (rev 646)
@@ -435,8 +435,13 @@
die("Parameter \$db not set in get_timeframe_data") if (!defined($db));
if (defined($available_timeframes)) {
- foreach (split(',', $available_timeframes)) {
- push @tf, GT::DateTime::name_to_timeframe($_);
+ foreach my $tf_name (split(',', $available_timeframes)) {
+ my $tf_code = GT::DateTime::name_to_timeframe($tf_name);
+ push @tf, $tf_code;
+ if (!defined($tf_code)) {
+ my $tfs = join("\n\t", map(GT::DateTime::name_of_timeframe($_), GT::DateTime::list_of_timeframe));
+ die("Invalid timeframe name in available_timeframes configuration item: $tf_name\n\nValid timeframes are: \n\t" . $tfs . "\n\n");
+ }
}
@tf = sort(@tf);
} else {
@@ -452,6 +457,12 @@
last if ($q->count > 0);
}
+if (!defined($q) || $q->count == 0) {
+my $msg="No data available to generate ".GT::DateTime::name_of_timeframe($timeframe)." data.";
+$msg.="\nAvailable timeframes are: ($available_timeframes)" if (defined($available_timeframes));
+die($msg);
+}
+
warn ("No data is available to complete the request for $code") if ($q && $q->count == 0);
my $calc = GT::Calculator->new($q);
$calc->set_code($code);