Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koa2 render出错时抛出异常 #17

Open
heerake opened this issue Mar 20, 2018 · 2 comments
Open

koa2 render出错时抛出异常 #17

heerake opened this issue Mar 20, 2018 · 2 comments

Comments

@heerake
Copy link

heerake commented Mar 20, 2018

目前会直接吃掉异常,返回undefined的content

@chang-ke
Copy link
Contributor

chang-ke commented Apr 2, 2018

能提供具体的错误和可复现代码吗?

@heerake
Copy link
Author

heerake commented Apr 3, 2018

@danmin25

let Koa = require('koa');
let xtpl = require('xtpl/lib/koa2');
let path = require('path');

let app = new Koa();

xtpl(app, {
    views: path.resolve(__dirname)
});

app.use(async (ctx) => {
    ctx.body = await ctx.render('./test', {
        number: 1
    });
});

app.listen(3333);

test.tpl内容为

{{number.noFunc(1)}}

错误在xtpl/lib/koa2, line55
没有处理error,是故意设计成这样的么

xtplRender(filePath, context, option)((e, data) => {
            content = data;
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants