Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Avoid throwing null pointer exceptions when package update fails #829

Merged
merged 1 commit into from
Aug 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/package-card.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,20 @@ class PackageCard extends View

update: ->
return unless @newVersion or @newSha
@packageManager.update @installablePack ? @pack, @newVersion, (error) =>
pack = @installablePack ? @pack
version = if @newVersion then "v#{@newVersion}" else "##{@newSha.substr(0, 8)}"
@packageManager.update pack, @newVersion, (error) =>
if error?
version = if @newVersion then "v#{newVersion}" else "##{@newSha.substr(0, 8)}"
console.error("Updating #{@type} #{@pack.name} to #{version} failed", error.stack ? error, error.stderr)
atom.assert false, "Package update failed", (assertionError) =>
assertionError.metadata = {
type: @type,
name: pack.name,
version: version,
errorMessage: error.message,
errorStack: error.stack,
errorStderr: error.stderr
}
console.error("Updating #{@type} #{pack.name} to #{version} failed:\n", error, error.stderr ? '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a notification instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point, although we'd like to keep this pull-request scoped to fixing the bug without changing how we present the error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I didn't notice that it was already a console.error beforehand.


uninstall: ->
@packageManager.uninstall @pack, (error) =>
Expand Down