-
Notifications
You must be signed in to change notification settings - Fork 21
Conversation
@keybase/updater-hackers |
https://keybase.atlassian.net/browse/DESKTOP-902 I shorted UpdateError to just Error since this is our custom error for package updater.
@keybase/updater-hackers bump ready |
@@ -57,11 +58,19 @@ func NewUpdater(source UpdateSource, config Config, log logging.Logger) *Updater | |||
} | |||
|
|||
// Update checks, downloads and performs an update | |||
func (u *Updater) Update(ctx Context) (*Update, error) { | |||
func (u *Updater) Update(ctx Context) (*Update, *Error) { |
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.
why return a *Error
rather than an error
interface?
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.
Yeah, sure, exposing custom error types in a public interface isn't common... and totally unnecessary here
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.
Cool, this will save you from ever needing an *Error
type, which can be buggy because of the crazy nil
v nil
semantics in Go.
Big question surrounding the use of an |
I changed around the error helper functions to not return a pointer.. instead using an errPtr function to change Error to pointer for return... basically I'm trying to avoid this: uerr := cancelErr(err)
return update, &uerr by doing this: return update, errPtr(cancelErr(err)) since you can't do Is this better? |
Seems more like the "golang way"?
Actually, I think I understand... the golang way is the use the error interface throughout and then use a type switch to get a the specific error when needed? If in reporting, for some reason the error is not out updater.Error type, then the error_type in reporting will be "unknown". |
@gabriel yeah, error interface + type switch is the way to go. |
* Add git diff * Add git clean
https://keybase.atlassian.net/browse/DESKTOP-902
I shorted UpdateError to just Error since this is our custom error for package updater.