Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class QiniuRequestError extends QiniuError {
* @description 由于跨域、证书错误、断网、host 解析失败、系统拦截等原因导致的错误
*/
export class QiniuNetworkError extends QiniuRequestError {
constructor(message: string, reqId: string = '') {
constructor(reqId = '', message: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

明显有问题 = =

super(0, reqId, message)
}
}
10 changes: 5 additions & 5 deletions src/upload/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Resume from './resume'
import Direct from './direct'
import Logger from '../logger'
import { QiniuError } from '../errors'
import { QiniuError, QiniuNetworkError, QiniuRequestError } from '../errors'
import { UploadCompleteData } from '../api'
import { Observable, IObserver, MB, normalizeUploadConfig } from '../utils'
import { Extra, UploadOptions, UploadHandlers, UploadProgress, InternalConfig } from './base'
import { Extra, UploadOptions, UploadHandlers, UploadProgress, Config } from './base'
import { HostPool } from './hosts'

export * from './base'
Expand Down Expand Up @@ -43,8 +43,8 @@ export default function upload(
key: string | null | undefined,
token: string,
putExtra?: Partial<Extra>,
config?: Partial<InternalConfig>
): Observable<UploadProgress, QiniuError, UploadCompleteData> {
config?: Config
): Observable<UploadProgress, QiniuError | QiniuRequestError | QiniuNetworkError, UploadCompleteData> {

// 为每个任务创建单独的 Logger
const logger = new Logger(token, config?.disableStatisticsReport, config?.debugLogLevel, file.name)
Expand All @@ -60,7 +60,7 @@ export default function upload(
// 创建 host 池
const hostPool = new HostPool(options.config.uphost)

return new Observable((observer: IObserver<UploadProgress, QiniuError, UploadCompleteData>) => {
return new Observable((observer: IObserver<UploadProgress, QiniuError | QiniuRequestError | QiniuNetworkError, UploadCompleteData>) => {
const manager = createUploadManager(options, {
onData: (data: UploadProgress) => observer.next(data),
onError: (err: QiniuError) => observer.error(err),
Expand Down