diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-12-25 22:03:19 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-12-25 22:03:19 -0800 |
commit | e9d72de48b15776f6b69a1436bfbb32a90e35993 (patch) | |
tree | 87f8bd6817e78dedde5e253274a1894cee2f455c | |
parent | 04a062e94d5350a33e468e5698e91fd5235a9c11 (diff) | |
download | teliva-e9d72de48b15776f6b69a1436bfbb32a90e35993.tar.gz |
gemini: better error-handling
-rw-r--r-- | gemini.tlv | 14 |
1 files 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) |