diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index ea06ff6..bf7c1c0 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -15,12 +15,19 @@ "forEditorLocaleCode": "en", "artPlayerLocaleCode": "en", "errors": { + "404": "Resource not found.", + "40001": "Invalid input parameters ({{message}}).", + "40002": "Upload failed.", + "40003": "Failed to create folder.", + "40004": "Object with the same name already exist.", "40006": "Not supported policy type.", - "40020": "Wrong password or email address.", + "40007": "Current group have no permission to perform such action.", + "40015": "Exceed aria2 batch size limit.", + "40016": "Path not found.", "40017": "This account has been blocked.", "40018": "This account is not activated.", "40019": "This feature is not enabled.", - "40001": "Invalid input parameters ({{message}}).", + "40020": "Wrong password or email address.", "40021": "User not found.", "40022": "Verification code not correct.", "40023": "Login session not exist.", @@ -38,8 +45,20 @@ "40039": "Group not found.", "40044": "File not found.", "40045": "Failed to list objects under given folder.", + "40047": "Failed to initialize filesystem.", + "40048": "Failed to create task", + "40049": "File size exceed limit.", + "40050": "File type not allowed.", + "40051": "Insufficient storage quota.", + "40052": "Invalid object name, please remove special characters.", + "40053": "Cannot perform such action on root folder", + "40054": "File with the same name is already being uploaded under this folder, please cleanup upload sessions.", + "40055": "File metadata mismatch.", "50001": "Database operation failed. ({{message}})", "50002": "Failed to sign the URL or request. ({{message}})", - "50005": "Internal error. ({{message}})" + "50004": "I/O operation failed. ({{message}})", + "50005": "Internal error.", + "50010": "Desired node is unavailable.", + "50011": "Failed to query file metadata." } } \ No newline at end of file diff --git a/public/locales/zh-CN/common.json b/public/locales/zh-CN/common.json index 4d4f18b..041bacc 100644 --- a/public/locales/zh-CN/common.json +++ b/public/locales/zh-CN/common.json @@ -15,12 +15,19 @@ "forEditorLocaleCode": "zh-CN", "artPlayerLocaleCode": "zh-cn", "errors": { + "404": "资源不存在", + "40001": "输入参数有误 ({{message}})", + "40002": "上传失败", + "40003": "目录创建失败", + "40004": "同名对象已存在", "40006": "不支持的存储策略类型", - "40020": "用户邮箱或密码错误", + "40007": "当前用户组无法进行此操作", + "40015": "超出最大离线下载任务数量限制", + "40016": "路径不存在", "40017": "该账号已被封禁", "40018": "该账号未激活", "40019": "此功能未启用", - "40001": "输入参数有误 ({{message}})", + "40020": "用户邮箱或密码错误", "40021": "用户不存在", "40022": "验证代码不正确", "40023": "登录会话不存在", @@ -38,8 +45,20 @@ "40039": "用户组不存在", "40044": "文件不存在", "40045": "无法列取目录下的对象", + "40047": "无法初始化文件系统", + "40048": "创建任务出错", + "40049": "文件大小超出限制", + "40050": "文件类型不允许", + "40051": "容量空间不足", + "40052": "对象名非法,请移除特殊字符", + "40053": "不支持对根目录执行此操作", + "40054": "话当前目录下已经有同名文件正在上传中,请尝试清空上传会话", + "40055": "文件信息不一致", "50001": "数据库操作失败 ({{message}})", "50002": "URL 或请求签名失败 ({{message}})", - "50005": "內部错误 ({{message}})" + "50004": "I/O 操作失败 ({{message}})", + "50005": "內部错误 ({{message}})", + "50010": "目标节点不可用", + "50011": "文件元信息查询失败" } } \ No newline at end of file diff --git a/src/component/FileManager/Modals.js b/src/component/FileManager/Modals.js index 95fd921..aed0ecd 100644 --- a/src/component/FileManager/Modals.js +++ b/src/component/FileManager/Modals.js @@ -2,7 +2,7 @@ import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "react-redux"; import PathSelector from "./PathSelector"; -import API from "../../middleware/Api"; +import API, { AppError } from "../../middleware/Api"; import { Button, CircularProgress, @@ -456,7 +456,7 @@ class ModalsCompoment extends Component { .then((response) => { const failed = response.data .filter((r) => r.code !== 0) - .map((r) => r.msg + (r.error ? r.error : "")); + .map((r) => new AppError(r.msg, r.code, r.error).message); if (failed.length > 0) { this.props.toggleSnackbar( "top", diff --git a/src/middleware/Api.ts b/src/middleware/Api.ts index 10662b5..29ac7cb 100644 --- a/src/middleware/Api.ts +++ b/src/middleware/Api.ts @@ -31,7 +31,7 @@ const instance = axios.create({ withCredentials: true, }); -class AppError extends Error { +export class AppError extends Error { constructor(message: string | undefined, public code: any, error: any) { super(message); this.code = code;