Update index.js

throw error if not handler is not defined.