         res.type(r.type) if r.type?
         if typeof result is 'string' then res.send result
         else return result
+
+    else
+      throw new Error "ZappaJS invalid handler of type #{typeof r.handler}: #{util.inspect r.handler}"
 
   # Register socket.io handlers.
   io?.sockets.on 'connection', (socket) ->

        res.type r.type if r.type?
        res.send r.handler
        return
    else
      app[r.verb] r.path, r.middleware, (req, res, next) ->
        ctx =
          app: app

log = console.log
fs = require 'fs'
path = require 'path'
util = require 'util'
uuid = require 'node-uuid'
methods = require 'methods'

