     _.extend options, pageTitles.PageTitles[options.page]
     options.subnav ?= 'subnav'
     fs.readFile "client/template/#{options.subnav}.eco", (err, subnavTemplate) ->
+      if err?
+        console.warn "Template #{options.page} not found when rendering server side"
+        return resp.send 500, {error: "Template not found: #{err}"}
+
       fs.readFile "client/template/nav.eco", (err, navTemplate) ->
+        if err?
+          console.warn "Template #{options.page} not found when rendering server side"
+          return resp.send 500, {error: "Template not found: #{err}"}
+
         getSessionUsersFromDB req.user, (usersObj) ->
           resp.render 'index',
               title: options.title or 'ScraperWiki'


addSSHKey = (req, resp) ->
  User.findByShortName req.user.effective.shortName, (err, user) ->
    if not req.body.key?
      return resp.send 400, error: 'Specify key'
    user.sshKeys.push req.body.key.trim()

  return next() if req.user.effective.shortName == req.params.user

  User.findByShortName req.params.user, (err, switchingTo) ->
    if err?
      return resp.send 500, error: "Unknown error #{err}"

    if switchingTo?.canBeReally and req.user.real.shortName in switchingTo.canBeReally
      next()
    else
