部署报错详细提示

This commit is contained in:
eoao
2025-08-28 22:22:00 +08:00
parent 375613c219
commit 6219a1474e
4 changed files with 22 additions and 0 deletions

View File

@@ -12,6 +12,19 @@ app.onError((err, c) => {
}else {
console.error(err);
}
if (err.message === `Cannot read properties of undefined (reading 'get')`) {
return c.text('初始化失败:KV数据库未绑定或变量名错误 Initialization failed: KV database not bound or invalid variable name');
}
if (err.message === `Cannot read properties of undefined (reading 'put')`) {
return c.text('初始化失败:KV数据库未绑定或变量名错误 Initialization failed: KV database not bound or invalid variable name');
}
if (err.message === `Cannot read properties of undefined (reading 'prepare')`) {
return c.text('初始化失败:D1数据库未绑定或变量名错误 Initialization failed: D1 database not bound or invalid variable name');
}
return c.json(result.fail(err.message, err.code));
});