部署报错详细提示

This commit is contained in:
eoao
2025-08-28 22:22:00 +08:00
parent 57b22f300e
commit 4c74e00493
4 changed files with 22 additions and 0 deletions
+13
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));
});
+1
View File
@@ -45,6 +45,7 @@ const en = {
roleNameExist: 'Role name already exists',
delDefRole: 'Default role cannot be deleted',
notJsonDomain: 'Environment variable "domain" must be in JSON format',
noDomainVariable: 'Environment variable domain cannot be empty',
noOsUpBack: 'Cannot upload background: R2 object storage not configured',
noOsDomainUpBack: 'Cannot upload background: R2 domain not configured',
starNotExistEmail: 'Starred email does not exist',
+1
View File
@@ -45,6 +45,7 @@ const zh = {
roleNameExist: '身份名已存在',
delDefRole: '默认身份不能删除',
notJsonDomain: '环境变量domain必须是JSON类型',
noDomainVariable: '环境变量domain不能为空',
noOsUpBack: 'r2对象存储未配置不能上传背景',
noOsDomainUpBack: 'r2域名未配置不能上传背景',
starNotExistEmail: '星标的邮件不存在',
@@ -21,8 +21,10 @@ const settingService = {
},
async query(c) {
const setting = await c.env.kv.get(KvConst.SETTING, { type: 'json' });
let domainList = c.env.domain;
if (typeof domainList === 'string') {
try {
domainList = JSON.parse(domainList)
@@ -30,6 +32,11 @@ const settingService = {
throw new BizError(t('notJsonDomain'));
}
}
if (!c.env.domain) {
throw new BizError(t('noDomainVariable'));
}
domainList = domainList.map(item => '@' + item);
setting.domainList = domainList;
return setting;