部署报错详细提示
This commit is contained in:
@@ -12,6 +12,19 @@ app.onError((err, c) => {
|
|||||||
}else {
|
}else {
|
||||||
console.error(err);
|
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));
|
return c.json(result.fail(err.message, err.code));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const en = {
|
|||||||
roleNameExist: 'Role name already exists',
|
roleNameExist: 'Role name already exists',
|
||||||
delDefRole: 'Default role cannot be deleted',
|
delDefRole: 'Default role cannot be deleted',
|
||||||
notJsonDomain: 'Environment variable "domain" must be in JSON format',
|
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',
|
noOsUpBack: 'Cannot upload background: R2 object storage not configured',
|
||||||
noOsDomainUpBack: 'Cannot upload background: R2 domain not configured',
|
noOsDomainUpBack: 'Cannot upload background: R2 domain not configured',
|
||||||
starNotExistEmail: 'Starred email does not exist',
|
starNotExistEmail: 'Starred email does not exist',
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const zh = {
|
|||||||
roleNameExist: '身份名已存在',
|
roleNameExist: '身份名已存在',
|
||||||
delDefRole: '默认身份不能删除',
|
delDefRole: '默认身份不能删除',
|
||||||
notJsonDomain: '环境变量domain必须是JSON类型',
|
notJsonDomain: '环境变量domain必须是JSON类型',
|
||||||
|
noDomainVariable: '环境变量domain不能为空',
|
||||||
noOsUpBack: 'r2对象存储未配置不能上传背景',
|
noOsUpBack: 'r2对象存储未配置不能上传背景',
|
||||||
noOsDomainUpBack: 'r2域名未配置不能上传背景',
|
noOsDomainUpBack: 'r2域名未配置不能上传背景',
|
||||||
starNotExistEmail: '星标的邮件不存在',
|
starNotExistEmail: '星标的邮件不存在',
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ const settingService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async query(c) {
|
async query(c) {
|
||||||
|
|
||||||
const setting = await c.env.kv.get(KvConst.SETTING, { type: 'json' });
|
const setting = await c.env.kv.get(KvConst.SETTING, { type: 'json' });
|
||||||
let domainList = c.env.domain;
|
let domainList = c.env.domain;
|
||||||
|
|
||||||
if (typeof domainList === 'string') {
|
if (typeof domainList === 'string') {
|
||||||
try {
|
try {
|
||||||
domainList = JSON.parse(domainList)
|
domainList = JSON.parse(domainList)
|
||||||
@@ -30,6 +32,11 @@ const settingService = {
|
|||||||
throw new BizError(t('notJsonDomain'));
|
throw new BizError(t('notJsonDomain'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!c.env.domain) {
|
||||||
|
throw new BizError(t('noDomainVariable'));
|
||||||
|
}
|
||||||
|
|
||||||
domainList = domainList.map(item => '@' + item);
|
domainList = domainList.map(item => '@' + item);
|
||||||
setting.domainList = domainList;
|
setting.domainList = domainList;
|
||||||
return setting;
|
return setting;
|
||||||
|
|||||||
Reference in New Issue
Block a user