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

[inspector] Use preconditions that throw exceptions instead of errors #270

Merged
merged 1 commit into from
May 14, 2024

Conversation

alexander-yakushev
Copy link
Member

@alexander-yakushev alexander-yakushev commented May 14, 2024

Misconfiguration throwing AssertionErrors makes them slip through cider-nrepl's with-safe-transport.

Overall, assertions are bad when integrating with other code.

@vemv
Copy link
Member

vemv commented May 14, 2024

I'd be happy as well with fixing with-safe-transport - seems fairly hard to guarantee across projects/time that we'll never use assertions.

@alexander-yakushev
Copy link
Member Author

Agreed – additionally handling assertion errors is reasonable in with-safe-transport, but not blanketly catching Throwable (which is a bad idea).

@bbatsov
Copy link
Member

bbatsov commented May 14, 2024

Do we even need those preconditions?

@alexander-yakushev
Copy link
Member Author

alexander-yakushev commented May 14, 2024

I'd say yes. For example, setting certain values to zero can hang the inspector or raise very low-level errors. Since those values can ultimately come from the user, we have to validate them somewhere. And I don't like the idea of repeating the validation on each layer (orchard, cider-nrepl, cider); I'd rather do that in a single place that knows what the values should look like (orchard) and flow the helpful errors back through the other layers.

Copy link
Member

@vemv vemv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion system isn't best for validating user input (since users can disable it, for one thing) so this seems a sensible change.

The cider-nrepl improvement would seem welcome as well.

@bbatsov
Copy link
Member

bbatsov commented May 14, 2024

I just assumed that bad data would result in exceptions, not lock-ups. If that's not the case - I guess we need those assertions. In general I've rarely found them useful in my work with Clojure, that's why I'm somewhat skeptical of their value.

@alexander-yakushev alexander-yakushev merged commit 921c4bb into master May 14, 2024
58 checks passed
@alexander-yakushev alexander-yakushev deleted the inspect-pre-ex branch May 14, 2024 13:57
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.

3 participants