 
   loadInstalled: (callback) ->
     args = ['ls', '--json']
+    errorMessage = 'Fetching local packages failed.'
     apmProcess = @runCommand args, (code, stdout, stderr) ->
       if code is 0
         try
           packages = JSON.parse(stdout)
         catch parseError
-          error = createJsonParseError('Fetching local packages failed.', parseError, stdout)
-          return callback(error)
-        callback(null, packages)
-      else
-        error = new Error('Fetching local packages failed.')
-        error.stdout = stdout
-        error.stderr = stderr
-        callback(error)
-
-    handleProcessErrors(apmProcess, 'Fetching local packages failed.', callback)
+          error = createJsonParseError(errorMessage, parseError, stdout)
+          return callback(error)
+        callback(null, packages)
+      else
+        error = new Error(errorMessage)
+        error.stdout = stdout
+        error.stderr = stderr
+        callback(error)
+
+    handleProcessErrors(apmProcess, errorMessage, callback)
 
   loadFeatured: (loadThemes, callback) ->
     unless callback


    atom.packages.deactivatePackage(name) if atom.packages.isPackageActive(name)

    onError = (error) =>
      @emitPackageEvent 'uninstall-failed', pack, error
      callback(error)

        callback?()
        @emitPackageEvent 'uninstalled', pack
      else
        error = new Error(errorMessage)
        error.stdout = stdout
        error.stderr = stderr
        onError(error)

    handleProcessErrors(apmProcess, errorMessage, onError)

  canUpgrade: (installedPackage, availableVersion) ->
    return false unless installedPackage?
