-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle missing GITHUB_TOKEN #23
Comments
Hi! :) I'm trying to look into this issue, and this is probably the first module to have its own error type, so I couldn't find much reference in terms of graceful error handling. The closest one might be in Currently I'm thinking functions that use |
Hi @loadre 👋🏻 Indeed, this is the first place where errors are introduced but more errors will be added later. We'll deal with them later as well. I agree that returning an empty list of issues is bad UX, since the user won't know there's an error. I propose the following plan:
Ideally, we want the same for PRs. |
Sounds good! On a side note, I wonder if it's a better option to change type t =
| Err of Gh.Client.error
| Issues of { ... } because it's unlikely that we get a list of issues alongside the client error. This could help get rid of invalid states down the road, but it would require further rewrite of functions that accept a |
@loadre I thought about this, and usually I love making illegal states unrepresentable. However, in this case, I feel like it'll introduce a lot of accidental complexity. First, functions like filtering of issues will become more complex github-tui/lib/tui/model/issue.ml Lines 16 to 23 in 9c07624
And second, I won't be able to change offset that easily. Lines 7 to 10 in 9c07624
In my view, this is a fine trade-off because there's only one place where we need to check for errors, and thus, the rest of the code doesn't need to care about it. Ensuring no invalid states will become quite invasive here. |
Currently,
github-tui
will fail at runtime with theNot_found
exception if theGITHUB_TOKEN
environment variable is not present:github-tui/lib/gh/client.ml
Lines 3 to 4 in f71814e
This is bad UX, so let's do the following:
error
inside theClient
module with one constructorNo_github_token
query
to return(string, error) result
Sys.getenv_opt
to getoption
instead of exceptionThe text was updated successfully, but these errors were encountered: