From e9d72de48b15776f6b69a1436bfbb32a90e35993 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 25 Dec 2021 22:03:19 -0800 Subject: gemini: better error-handling --- gemini.tlv | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gemini.tlv b/gemini.tlv index 2198c7a..ff38919 100644 --- a/gemini.tlv +++ b/gemini.tlv @@ -469,16 +469,20 @@ > options = 'all', > } > local conn = socket.tcp() - > conn:connect(parsed_url.host, parsed_url.port or 1965) + > local conn2, err = conn:connect(parsed_url.host, parsed_url.port or 1965) + > clear(state.lines) + > state.highlight_index = 0 -- highlighted link not computed yet + > if conn2 == nil then + > table.insert(state.lines, err) + > return + > end > conn, err = ssl.wrap(conn, params) > if conn == nil then - > io.write(err) - > os.exit(1) + > table.insert(state.lines, err) + > return > end > conn:dohandshake() > conn:send(url .. "\r\n") - > clear(state.lines) - > state.highlight_index = 0 -- highlighted link not computed yet > local line, err = conn:receive() > if line == nil then > table.insert(state.lines, err) -- cgit 1.4.1-2-gfad0