Browse Source

improve error handling in faqs view

master
René Wagner 4 months ago
parent
commit
5b8503c2d3
  1. BIN
      data/data.sqlite.example
  2. 7
      faqs.pl

BIN
data/data.sqlite.example

7
faqs.pl

@ -44,7 +44,7 @@ sub sql
if ( $query =~ /faq=([0-9]+)/i ) {
return "SELECT q.* FROM questions q LEFT JOIN tags_questions tq ON q.id = tq.q_id WHERE q.id = $1";
}
write_response('INTERNAL_SERVER_ERROR', 'CGI execution error', undef);
write_response('CGI_ERROR', 'invalid query string', undef);
}
sub faqs
@ -60,15 +60,16 @@ sub faqs
else {
foreach (@rows) {
push @return, sprintf("## %s", @$_[1]);
push @return, (@$_[2], '');
my @tags = $dbh->selectall_array("SELECT id, name FROM tags t LEFT JOIN tags_questions tq ON tq.t_id = t.id WHERE tq.q_id = @$_[0];");
if ( scalar @tags ) {
push @return, ('', '### Tags');
push @return, ('### tags');
foreach (@tags) {
push @return, sprintf("=> ./faqs.pl?tag=%d %s", @$_[0], @$_[1]);
}
push @return, '';
}
push @return, ('', '### Answer', @$_[2], '');
}
}
$dbh->disconnect();

Loading…
Cancel
Save