关闭

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

标签: github异常处理博客Hexo
1939人阅读 评论(1) 收藏 举报
分类:

异常

这里主要收集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

0
0

猜你在找
【直播】机器学习&数据挖掘7周实训--韦玮
【套餐】系统集成项目管理工程师顺利通关--徐朋
【直播】3小时掌握Docker最佳实战-徐西宁
【套餐】机器学习系列套餐(算法+实战)--唐宇迪
【直播】计算机视觉原理及实战--屈教授
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之矩阵--黄博士
【套餐】微信订阅号+服务号Java版 v2.0--翟东平
【直播】机器学习之凸优化--马博士
【套餐】Javascript 设计模式实战--曾亮
查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:365825次
    • 积分:4705
    • 等级:
    • 排名:第6146名
    • 原创:116篇
    • 转载:9篇
    • 译文:1篇
    • 评论:131条
    博客简介
    已解决的BUG为何总是重复出现?
    已经定好的产品需求为何再次修改?
    托管机房的服务器为何屡遭黑手?
    SVN服务器上的代码为何突然消失?
    线上服务器频频宕机,究竟是何人所为?
    拒绝服务攻击夜夜出现,究竟是人是鬼?
    生产数据库集群一夜之间不见踪影的背后又隐藏着什么?
    这一切的背后,是技术的缺陷,还是管理的沦丧?
    是黑客的爆发还是运维的无奈?
    敬请关注每晚12点可能不更新的年度巨献《微笑哥的架构之路》让我们跟随着大大的微笑博客走进一个程序员的内心世界……
    博客专栏
    最新评论