-
Notifications
You must be signed in to change notification settings - Fork 180
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
Premature error fix for issue #353 #357
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9c02ccc
fix(keybinds): Address premature error re; #353
Omnikron13 e189492
style: capitalisation in comment
Omnikron13 bf2338e
fix(keybinds): replace struct with map for template inputs (#353)
Omnikron13 cce3e09
fix(keybinds): replace fatal error with bubbletea error message
Omnikron13 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the log.Fatal on line 128 and instead return a tea.Cmd?
Use a more appropriate message though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, no I don't think that is the right approach...
Templates can be pretty complex. They can be recursively nested into a tree structure, be populated out in multiple stages by different calls to the
Execute
functions with different sources and types of data, potentially across multiple goroutines simultaneously.The values passed in can be chained on one another (I presume to key into a map or struct which is another value passed in). They can be (zero-argument*) functions/methods that implements some kind of literal piping with
|
to produce the final substitution. I believe they may return a 2nd err return which will be propagated out ultimately. ( * there is a manner in which the final piece of data passed in, can have arguments, but honestly there's a lot going on in there, and a lot of ways and reasons it might spit errors at you. )There's definitely cases where it will error on 'empty or incomplete' template, other internal/syntactic issues, unexpected data types or values, etc...
The
Option
that this branch sets is essentially stating;While trivial current uses seem in the source to suggest the other values passed in are reliable, future additions may not be. The writer of the template might typo key/member names, screw up their syntax, etc. and cause an unrelated error, or the template may have its own reasons to.
It could certainly complicate the error handing if you want to tease any nuance out, though I think you may be able to simple propagate the errors, or wrapped versions of them, up to wherever and how that gets communicated to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how this relates to the fact you can show a log to the user using the
tea.Command
instead of crashing the app with fatal.Log.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, think I totally misread/missed the point there... I didn't put any of the
log.Fatal()
's in, so I think my mind went elsewhere.There's a few sprinkled about, though I confess I'm not really up to speed with bubbletea yet, so not sure I was even aware what that snippet was doing tbh. >_>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made that change, though #362 would supersede this PR if it is the design direction you favour.