Add more descriptive error for lawn mower link print error. - gopher-lawn - The gopher lawn gopher directory project.
 (HTM) git clone git://bitreich.org/gopher-lawn/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/gopher-lawn/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
       ---
 (DIR) commit c3a8dd8aabb09e4148787a9b5ceeebb288b8e3fb
 (DIR) parent 2b1d818d03dbd3099e6b9cc9ca552bc20676d9dd
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Sat, 29 Jul 2023 15:35:08 +0200
       
       Add more descriptive error for lawn mower link print error.
       
       Diffstat:
         M lawn-mower/lawn-mower.py            |      17 +++++++++++------
       
       1 file changed, 11 insertions(+), 6 deletions(-)
       ---
 (DIR) diff --git a/lawn-mower/lawn-mower.py b/lawn-mower/lawn-mower.py
       @@ -210,12 +210,17 @@ def main(args):
                        return rtext
        
                def printlink(link):
       -                rtext = "[%s|%s|%s|%s|%s]\n" \
       -                        % (linktype2gopher(link),\
       -                           link["linkname"],\
       -                           link["selector"],\
       -                           link["host"],\
       -                           link["port"])
       +                try:
       +                        rtext = "[%s|%s|%s|%s|%s]\n" \
       +                                % (linktype2gopher(link),\
       +                                   link["linkname"],\
       +                                   link["selector"],\
       +                                   link["host"],\
       +                                   link["port"])
       +                except KeyError:
       +                        print("Error printing link in: %s" % (link))
       +                        return ""
       +
                        if "description" in link:
                                rtext += printdescription(link["description"])
                        rtext += "\n"