 
       when 'Reinitialize', 'Update'
         computeController.reinitStack stack, (err, newStack) =>
-          return @onMenuItemClickError 'reinitializing', template.getId()  if err
+          return @onMenuItemClickError 'reinitializing', err, template.getId()  if err
           appManager.tell 'Stackeditor', 'reloadEditor', template.getId(), newStack.stack.getId()
 
       when 'Clone'
         computeController.fetchStackTemplate template.getId(), (err, template) =>
-          return @onMenuItemClickError 'cloning'  if err
+          return @onMenuItemClickError 'cloning', err  if err
           template.clone (err, template) =>
-            return @onMenuItemClickError 'cloning'  if err
+            return @onMenuItemClickError 'cloning', err  if err
             router.handleRoute "/Stack-Editor/#{template.getId()}"
 
       when 'Destroy VMs'
         computeController.ui.askFor 'deleteStack', {}, (status) =>
           return  unless status.confirmed
           computeController.destroyStack stack, (err) =>
-            return @onMenuItemClickError 'destroying'  if err
+            return @onMenuItemClickError 'destroying', err  if err
           , followEvents = no
 
       when 'Delete'

    @headers = []


  onMenuItemClickError: (action, templateId) ->

    debug "error while #{action}", { templateId }

    showError "Error occured while #{action} the template"



      when 'Make Team Default'
        computeController.fetchStackTemplate template.getId(), (err, template) =>
          return @onMenuItemClickError 'making team default', err  if err
          if template
            computeController.makeTeamDefault template

      when 'Share With Team'
        computeController.fetchStackTemplate template.getId(), (err, template) =>
          return @onMenuItemClickError 'sharing', err  if err
          if template
            computeController.setStackTemplateAccessLevel template, 'group'

      when 'Make Private'
        computeController.fetchStackTemplate template.getId(), (err, template) =>
          return @onMenuItemClickError 'cloning', err  if err
          if template
            computeController.setStackTemplateAccessLevel template, 'private'

