chiark / gitweb /
Discriminate error types in login.
authorSimon Tatham <anakin@pobox.com>
Wed, 24 Jan 2024 08:44:59 +0000 (08:44 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 24 Jan 2024 20:08:37 +0000 (20:08 +0000)
commit029bf84be0c0d6931d04da99a288b2a72c098469
treeec11c543286e5de25b947fc6abcaf01d80ba6957
parent6a112a376aae220100b678b2e95f7507e2000b4c
Discriminate error types in login.

ClientError and ConfigError should be handled differently. The former
suggests you did something wrong in account setup, and you might be
able to recover by doing it again properly (e.g. not misspelling the
server hostname), so we print the error in the TUI and let the user
try again. But the latter probably means you have to sort out your
local account setup (e.g. XDG dirs aren't working, or %APPDATA% isn't
set), and that's more like the kind of fatal error where you quit the
client and fix it externally.

So I've made a new LoginError enum to act as the union of those two
types and also indicate which you have. ConfigError is now passed
back to terminate the TUI completely.

This also means I'm no longer abusing TopLevelError for the union
error type returned by e.g. confirm_registration_fallible. That was
bad in its own way because it prefixed 'mastodonochrome: error:' to
the error description as if it were reporting on the terminal.
src/login.rs
src/tui.rs