Skip to content
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

fix(cli/rm/rm.go): using panic is not user friendly #1608

Merged
merged 3 commits into from
May 17, 2024
Merged

Conversation

bassosimone
Copy link
Contributor

I manually tested the cli and concluded that it's too easy to reach the panic caused by runtimex.Try0 over there and it would expose panics to users too frequently.

Let's just convert those into normal error checks. Here is what we would previously get:

% ./ooniprobe rm
? Are you sure you wish to delete the result #0  [Use arrows to move, type to filter]
  true
> false
panic: Try0: interrupt

[...]

So, here I just pressed ^D and got a panic. Ouch!

After the diff, we have this:

% ./ooniprobe rm
? Are you sure you wish to delete the result #0 false
   ⨯ failure in main command   error=canceled by user

and:

% ./ooniprobe rm --all
? Are you sure you wish to delete ALL results false
   ⨯ failure in main command   error=canceled by user

It seems much better, isn't it?

Part of the QA for ooni/probe#2722

I manually tested the cli and concluded that it's too easy to
reach the panic caused by runtimex.Try0 over there and it would
expose panics to users too frequently.

Let's just convert those into normal error checks. Here is
what we would previously get:

```
% ./ooniprobe rm
? Are you sure you wish to delete the result #0  [Use arrows to move, type to filter]
  true
> false
panic: Try0: interrupt

[...]
```

So, here I just pressed ^D and got a panic. Ouch!

After the diff, we have this:

```
% ./ooniprobe rm
? Are you sure you wish to delete the result #0 false
   ⨯ failure in main command   error=canceled by user
```

and:

```
% ./ooniprobe rm --all
? Are you sure you wish to delete ALL results false
   ⨯ failure in main command   error=canceled by user
```

It seems much better, isn't it?

Part of the QA for ooni/probe#2722
@bassosimone bassosimone requested a review from hellais as a code owner May 17, 2024 12:14
@bassosimone bassosimone merged commit 5493975 into master May 17, 2024
19 checks passed
@bassosimone bassosimone deleted the issue/2722j branch May 17, 2024 12:51
bassosimone added a commit that referenced this pull request May 17, 2024
I manually tested the cli and concluded that it's too easy to reach the
panic caused by runtimex.Try0 over there and it would expose panics to
users too frequently.

Let's just convert those into normal error checks. Here is what we would
previously get:

```
% ./ooniprobe rm
? Are you sure you wish to delete the result #0  [Use arrows to move, type to filter]
  true
> false
panic: Try0: interrupt

[...]
```

So, here I just pressed ^D and got a panic. Ouch!

After the diff, we have this:

```
% ./ooniprobe rm
? Are you sure you wish to delete the result #0 false
   ⨯ failure in main command   error=canceled by user
```

and:

```
% ./ooniprobe rm --all
? Are you sure you wish to delete ALL results false
   ⨯ failure in main command   error=canceled by user
```

It seems much better, isn't it?

Part of the QA for ooni/probe#2722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant