优化文集导出异常的异常捕获和提示

This commit is contained in:
yangjian 2021-06-01 17:04:50 +08:00
parent 942f769e06
commit d6cb037b58
2 changed files with 10 additions and 2 deletions

View File

@ -5,6 +5,8 @@
- [新增]文档页面支持OGP协议
- [修复]开启「全站登录」后URL跳转异常的问题
- [优化]用户禁止同名文集创建,文集下禁止同名文档创建;
- [优化]文集导出异常提示;
### v0.6.7 2021-05-29
- [新增]表格文档支持Excel文件(.xlsx格式)导入;

View File

@ -2031,9 +2031,11 @@ def report_md(request):
md_file_filename = os.path.split(md_file_path)[-1] # 提取文件名
md_file = "/media/reportmd_temp/"+ md_file_filename # 拼接相对链接
return JsonResponse({'status':True,'data':md_file})
except ObjectDoesNotExist as e:
return JsonResponse({'status': False, 'data': _('文集不存在')})
except Exception as e:
logger.exception(_("导出文集MD文件出错"))
return JsonResponse({'status':False,'data':_('文集不存在')})
return JsonResponse({'status': False, 'data': _('导出文集异常')})
elif types == 'multi':
project_list = pro_id.split(',')
for project in project_list:
@ -2045,7 +2047,11 @@ def report_md(request):
project_id_list = project_list,
username = request.user.username
)
md_file_path = project_md.work() # 生成并获取MD文件压缩包绝对路径
try:
md_file_path = project_md.work() # 生成并获取MD文件压缩包绝对路径
except:
logger.exception("文集导出异常")
return JsonResponse({'status': False, 'data': _('文集导出异常')})
md_file_filename = os.path.split(md_file_path)[-1] # 提取文件名
md_file = "/media/reportmd_temp/" + md_file_filename # 拼接相对链接
return JsonResponse({'status': True, 'data': md_file})