gmnifaq

Unnamed repository; edit this file 'description' to name the repository.
git clone git://code.clttr.info/gmnifaq.git
Log | Files | Refs | README | LICENSE

commit 5b8503c2d37e7d32484bd7128f903a4f97bee9d8
parent 98ab6ca1ab3770d925bed026084215e36cf65913
Author: René Wagner <rwagner@rw-net.de>
Date:   Fri, 26 Feb 2021 22:14:38 +0100

improve error handling in faqs view

Diffstat:
Mdata/data.sqlite.example | 0
Mfaqs.pl | 7++++---
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/data/data.sqlite.example b/data/data.sqlite.example Binary files differ. diff --git a/faqs.pl b/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();