Hexo在Github中搭建博客系统(6)异常处理

转载 2016年08月29日 10:03:31

异常

这里主要收集Hexo在搭建博客的时候出现的异常以及处理方案

在进行启动服务器模拟查看时hexo s –debug出现的启动异常

(1) 无法执行now函数异常

1.1 异常内容

13:51:28.741 FATAL (unknown path) [Line 7, Column 533]
  Error: Unable to call `now`, which is undefined or falsey
Template render error: (unknown path) [Line 7, Column 533]
  Error: Unable to call `now`, which is undefined or falsey
    at Object.exports.prettifyError (/Users/hushuang/hexosite/node_modules/nunjucks/src/lib.js:34:15)
    at /Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:485:31
    at root [as rootRenderFunc] (eval at <anonymous> (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:564:24), <anonymous>:20:3)
    at Obj.extend.render (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:478:15)
    at Obj.extend.renderString (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:326:21)
    at /Users/hushuang/hexosite/node_modules/hexo/lib/extend/tag.js:66:9
    at Promise._execute (/Users/hushuang/hexosite/node_modules/bluebird/js/release/debuggability.js:272:9)
    at Promise._resolveFromExecutor (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:475:18)
    at new Promise (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:77:14)
    at Tag.render (/Users/hushuang/hexosite/node_modules/hexo/lib/extend/tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (/Users/hushuang/hexosite/node_modules/hexo/lib/hexo/post.js:253:16)
    at /Users/hushuang/hexosite/node_modules/hexo/lib/hexo/render.js:65:19
    at tryCatcher (/Users/hushuang/hexosite/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:685:18)
    at Async._drainQueue (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)

1.2 原因

这类异常一般是文章中使用了now( ), 小括号( )属于特殊字符,在编译文章时将now( )当函数处理了,结果找不到函数,就报错了。

1.3 解决方案

可以参考Markdown语法第(0)章-特殊字符
将now( )的小括号通过&#40; &#41; 进行转换


(2) 意外的标记异常

2.1 异常内容

14:55:15.987 FATAL (unknown path) [Line 119, Column 62]
  unexpected token: }}
Template render error: (unknown path) [Line 119, Column 62]
  unexpected token: }}
    at Object.exports.prettifyError (/Users/hushuang/hexosite/node_modules/nunjucks/src/lib.js:34:15)
    at Obj.extend.render (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:468:27)
    at Obj.extend.renderString (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:326:21)
    at /Users/hushuang/hexosite/node_modules/hexo/lib/extend/tag.js:66:9
    at Promise._execute (/Users/hushuang/hexosite/node_modules/bluebird/js/release/debuggability.js:272:9)
    at Promise._resolveFromExecutor (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:475:18)
    at new Promise (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:77:14)
    at Tag.render (/Users/hushuang/hexosite/node_modules/hexo/lib/extend/tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (/Users/hushuang/hexosite/node_modules/hexo/lib/hexo/post.js:253:16)
    at /Users/hushuang/hexosite/node_modules/hexo/lib/hexo/render.js:65:19
    at tryCatcher (/Users/hushuang/hexosite/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/Users/hushuang/hexosite/node_modules/bluebird/js/release/promise.js:685:18)
    at Async._drainQueue (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues (/Users/hushuang/hexosite/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)

2.2 原因

这类异常一般是文章中使用了大括号 { } 这个特殊字符,且没有转义导致编译不通过

2.3 解决方案

可以参考Markdown语法第(0)章-特殊字符
将 { } 的大括号通过&#123; &#125; 进行转换


(3) 模板渲染错误异常

3.1 异常内容

Template render error: parseSignature: expected comma after expression
        at Error.exports.TemplateError (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/lib.js:51:19)
        at Object.extend.fail (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:64:15)
        at Object.extend.parseSignature (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1077:22)
        at Object.extend.parsePostfix (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:616:47)
        at Object.extend.parsePrimary (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:933:29)
        at Object.extend.parseUnary (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:882:25)
        at Object.extend.parsePow (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:856:25)
        at Object.extend.parseMod (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:844:25)
        at Object.extend.parseFloorDiv (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:832:25)
        at Object.extend.parseDiv (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:820:25)
        at Object.extend.parseMul (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:808:25)
        at Object.extend.parseSub (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:796:25)
        at Object.extend.parseAdd (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:784:25)
        at Object.extend.parseCompare (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:751:25)
        at Object.extend.parseIn (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:720:23)
        at Object.extend.parseNot (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:716:21)
        at Object.extend.parseAnd (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:698:25)
        at Object.extend.parseOr (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:686:25)
        at Object.extend.parseInlineIf (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:668:25)
        at Object.extend.parseExpression (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:663:25)
        at Object.extend.parseNodes (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1158:30)
        at Object.extend.parse (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1173:46)
        at Object.extend.parseUntilBlocks (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1111:24)
        at NunjucksBlock._parseBody (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/extend/tag.js:111:21)
        at NunjucksBlock.parse (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/extend/tag.js:105:19)
        at Object.extend.parseStatement (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:540:36)
        at Object.extend.parseNodes (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1151:30)
        at Object.extend.parseAsRoot (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1177:42)
        at Object.module.exports.parse (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/parser.js:1199:18)
        at Object.module.exports.compile (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/compiler.js:1118:48)
        at Obj.extend._compile (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/environment.js:444:35)
        at Obj.extend.compile (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/environment.js:433:18)
        at null.<anonymous> (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/environment.js:378:22)
        at Object.exports.withPrettyErrors (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/lib.js:24:16)
        at Obj.extend.render (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/environment.js:374:20)
        at Obj.extend.renderString (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/nunjucks/src/environment.js:261:21)
        at /media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/extend/tag.js:56:9
        at tryCatcher (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/util.js:24:31)
        at Promise._resolveFromResolver (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/promise.js:427:31)
        at new Promise (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/promise.js:53:37)
        at Tag.render (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/extend/tag.js:55:10)
        at Object.tagFilter [as onRenderEnd] (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/hexo/post.js:253:16)
        at Promise.then.then.then.output (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/lib/hexo/render.js:55:19)
        at tryCatcher (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/util.js:24:31)
        at Promise._settlePromiseFromHandler (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/promise.js:454:31)
        at Promise._settlePromiseAt (/media/WinE/User/Documents/howiefh.github.io/node_modules/hexo/node_modules/bluebird/js/main/promise.js:530:18)

3.2 原因

这类异常一般是文章中使用了某个特殊字符, 解析时讲表达式中的内容按函数处理了,特殊字符没有转义导致编译不通过,就像下面的内容

参数 说明
repo OpenShift 库(Repository)地址
message 自定提交信息 (默认为 Site updated: { { now(’YYYY-MM-DD HH:mm:ss’) } })

3.3 解决方案

可以参考Markdown语法特殊字符处理 这章内容
将特殊字符通过转义进行转换
当然,最好的方案是避免写特殊字符


下一节:万网域名解析到Github Pages

相关文章推荐

mac下已安装的ssh的id_rsa.pub文件位置

找到mac中安装的ssh的id_rsa.pub文件位置的方法

Hexo在Github中搭建博客系统(5)Markdown语法

前面我们已经知道怎么搭博客系统、发布、创建文章,现在到了创建内容的时候,需要熟练掌握Markdown的语法基本语法(0) 特殊字符之所以把特殊字符放到最前面,就是因为Markdown对特殊字符处理不是...

mac 上node.js环境的安装与测试

一 摘要如何大家之前做过web服务器的人都知道,nginx+lua与现在流行的node.js都是可以做web服务器的,前者在程序的写法和配置上要比后者麻烦,但用起来都是差不多.在这里建议大家如果对lu...

Hexo在Github中搭建博客系统(4)建菜单写文章

在Hexo博客系统中, 可以创建菜单、文章、分类、标签。在我们的主题中,菜单和文章需要手动创建,而分类和标签不用手动创建,一、创建菜单在blog目录创建一个新的菜单$ hexo new page "g...

Hexo在Github中搭建博客系统(7)万网域名解析到Github Pages

在万网上买域名是相对便宜的,如何直接将域名指向Github Pages呢?一、购买域名选域名登录阿里云万网,根据你自己想好的域名去查询那些网站可以购买。 如果是个人网站,一般以姓名全拼进行注册,拼音...

Hexo在Github中搭建博客系统(3)Hexo安装主题

一、找到你喜欢的主题在Hexo主题 ( https://hexo.io/themes/ )页面,你可以欣赏到很多很优秀的主题,他们实在是太酷了! 二、下载主题如果你点击图片,就会跳到这个主题的博客,...

Mac 安装 nodejs (图文详细步骤)

Mac 下 安装 nodejs

Hexo在Github中搭建博客系统(2)Hexo一键发布文章到Github

一、一键部署到Github(1) 配置Github在blog目录,打开_config.yml $ vim _config.yml修改配置文件_config.yml中deploy下的内容 68 # D...

GitHub hexo搭建个人博客

  • 2017-06-10 23:53
  • 1.37MB
  • 下载

Mac系统下使用Hexo+GitHub搭建博客

前言     最近发现身边的小伙伴都搞了博客,这段工作不是很忙,自己也打算搞一个玩玩。     在网上查到有人基于WordPress搭建了博客,这个需要数据库啊,服务器之类的,感觉有点麻烦,后来在网上...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)