This repository was archived by the owner on Sep 9, 2025. It is now read-only.
Open
Conversation
jwm4
approved these changes
Jan 29, 2025
Contributor
jwm4
left a comment
There was a problem hiding this comment.
This seems like a sensible idea.
|
|
||
| The historically pervasive pattern for exception handling during application runtime is to catch internally raised exceptions in the CLI layer and use `click.secho` followed by `click.exceptions.Exit` to display a useful error message to the user before exiting the application. This leaves a risk of intermediate calls between the site of the exception and the user-facing layer changing, leading to missed new exceptions and outdated caught exceptions. A second issue is that of discoverability and verification: given a `click.exceptions.Exit` exception handling, it is not clear from the code where the caught exception originates from in the call stack, and, similarly, given a piece of code that can raise an exception, it is not clear from the local code whether that exception is properly handled in the CLI layer without investigation. | ||
|
|
||
| These issues will compound whenever REST APIs begin development. |
Contributor
There was a problem hiding this comment.
and/or whenever the SDK APIs begin development.
nathan-weinberg
approved these changes
Jan 29, 2025
Member
nathan-weinberg
left a comment
There was a problem hiding this comment.
Generally I agree with this, worth calling out that some of this work is ongoing in the Core repo as part of instructlab/instructlab#2325
Signed-off-by: Anastas Stoyanovsky <astoyano@redhat.com>
This was referenced Jan 30, 2025
Closed
booxter
reviewed
Jan 30, 2025
| * CLI layer error handling will be easy to understand and trace. | ||
| * Whenever REST APIs are developed, HTTP error codes should be easier to be associated with specific exceptions. | ||
| * It should be easier to compose useful error messages for the user. | ||
| * It should be easier to correctly scope exception handling (consider a `URLError` raised about SSL verification, for example, versus a custom `SSlVerificationException`). |
Contributor
There was a problem hiding this comment.
I'm with you in general but not for this specific example (as I expressed in the patch), for the reason that we cannot and should not enumerate all the possible ways a request may fail, so letting URLError bubble up is fine here. (Caught further up the call stack and transformed into ilab specific exception as needed.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.