feat(OneDrive): show retry-after duration in error message if request is throttled, and mark such error as retryable.

This commit is contained in:
HFO4 2022-10-15 16:33:17 +08:00
parent 547078fa21
commit 2ca4a957a5
4 changed files with 18 additions and 1 deletions

View File

@ -298,6 +298,7 @@
"chunkUploadError": "Failed to upload chunk [{{index}}].",
"conflictError": "The upload task for files with the same name is already being processed.",
"chunkUploadErrorWithMsg": "Chunk upload failed: {{msg}}",
"chunkUploadErrorWithRetryAfter": "(Please retry after {{retryAfter}}s)",
"emptyFileError": "Uploading empty files to OneDrive is not supported, please create empty files via the Create File button.",
"finishUploadError": "Unable to complete file upload.",
"finishUploadErrorWithMsg": "Unable to complete file upload: {{msg}}",

View File

@ -298,6 +298,7 @@
"chunkUploadError": "分片 [{{index}}] 上传失败",
"conflictError": "同名文件的上传任务已经在处理中",
"chunkUploadErrorWithMsg": "分片上传失败: {{msg}}",
"chunkUploadErrorWithRetryAfter": "(请在 {{retryAfter}} 秒后重试)",
"emptyFileError": "暂不支持上传空文件至 OneDrive请通过创建文件按钮创建空文件",
"finishUploadError": "无法完成文件上传",
"finishUploadErrorWithMsg": "无法完成文件上传: {{msg}}",

View File

@ -228,9 +228,23 @@ export class OneDriveChunkError extends UploaderError {
}
public Message(): string {
return i18next.t(`uploader.chunkUploadErrorWithMsg`, {
let msg = i18next.t(`uploader.chunkUploadErrorWithMsg`, {
msg: this.message,
});
if (this.response.error.retryAfterSeconds != undefined){
msg += " "+i18next.t(`uploader.chunkUploadErrorWithRetryAfter`, {
retryAfter: this.response.error.retryAfterSeconds,
})
}
return msg;
}
public Retryable(): boolean {
return (
super.Retryable() || this.response.error.retryAfterSeconds != undefined
);
}
}

View File

@ -76,6 +76,7 @@ export interface OneDriveError {
innererror?: {
code: string;
};
retryAfterSeconds?: number;
};
}