如果视图页面不可用,Sails.js路由将返回JSON响应而非错误页面

时间:2016-10-25 13:19:24

标签: sails.js

问题:我在sails routes.js中有一个条目,比如 -

'/agent-details': { view: 'agents/agent-details' }

但我在view / agents文件夹中没有此文件。

访问 / agent-details 网址时,会返回JSON响应

    {
      "message": "Could not render view \"agents/agent-details\".  Tried locating view file @ \"/Users/user/ckr/sails/proj/views/agents/agent-details\". Layout configured as \"layouts/public\", so tried using layout @ \"/Users/user/ckr/sails/proj/views/layouts/public\")",
      "code": "E_VIEW_FAILED",
      "status": 500,
      "view": {
        "name": "agents/agent-details",
        "root": "/Users/user/ckr/sails/proj/views",
        "defaultEngine": "ejs",
        "ext": ".ejs"
      }
    }

但我希望回复500.ejs / 404.ejs。

希望我能得到一些解决方案。 谢谢!!!

0 个答案:

没有答案