Hexo, Github에 블로그 시스템 구축 (6) 예외 처리

31740 단어 Hexo

이상


여기에는 Hexo가 블로그를 구축할 때 나타나는 이상과 처리 방안을 주로 수집합니다.
시작 서버 시뮬레이션 보기 중 hexos – 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  (/Users/hushuang/hexosite/node_modules/nunjucks/src/environment.js:564:24), :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 () 의 괄호를 통과합니다( ) 변환하기

(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) 장 - 특수 문자는 의 대괄호를 통과합니다{ } 변환하기

(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. (/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 솔루션


마크다운 문법의 특수 문자 처리를 참고하여 이 장의 내용을 특수 문자를 전의를 통해 변환할 수 있다. 물론 가장 좋은 방안은 특수 문자를 쓰지 않는 것이다
다음 섹션: Github Pages의 WAN 도메인 이름 분석

좋은 웹페이지 즐겨찾기