 
       when 'Make Team Default'
         computeController.fetchStackTemplate template.getId(), (err, template) =>
-          return @onMenuItemClickError 'making team default'  if err
+          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'  if err
+          return @onMenuItemClickError 'sharing', err  if err
           if template
             computeController.setStackTemplateAccessLevel template, 'group'
 
       when 'Make Private'
         computeController.fetchStackTemplate template.getId(), (err, template) =>
-          return @onMenuItemClickError 'cloning'  if err
+          return @onMenuItemClickError 'cloning', err  if err
           if template
             computeController.setStackTemplateAccessLevel template, 'private'
 

    @headers = []


  onMenuItemClickError: (action, templateId) ->

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

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


        router.handleRoute "/Stack-Editor/#{template.getId()}"

      when 'Initialize'
        template.generateStack { verify: yes }, (err, res) =>
          return @onMenuItemClickError 'initializing', err, template.getId()  if err
          { stack } = res
          router.handleRoute "/Stack-Editor/#{template.getId()}/#{stack.getId()}"
          appManager.tell 'Stackeditor', 'reloadEditor', template.getId(), stack.getId()
