@jetthai/cuora 1.1.481-api.0 → 1.1.481-api.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/request/request.js +10 -2
package/package.json
CHANGED
package/src/request/request.js
CHANGED
|
@@ -266,9 +266,14 @@ export default class Request {
|
|
|
266
266
|
return gate
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
+
// 帶 ERR_800 讓下游既有的 `if (!error.code)` 判斷(如 Sentry 上報)把取消視為預期錯誤
|
|
270
|
+
_cancelledError() {
|
|
271
|
+
return Object.assign(new Error(CANCELLED_MESSAGE), { code: 'ERR_800' })
|
|
272
|
+
}
|
|
273
|
+
|
|
269
274
|
_throwIfRevoked() {
|
|
270
275
|
if (this.revokedToken && this.getToken() === this.revokedToken) {
|
|
271
|
-
throw
|
|
276
|
+
throw this._cancelledError()
|
|
272
277
|
}
|
|
273
278
|
}
|
|
274
279
|
|
|
@@ -316,7 +321,7 @@ export default class Request {
|
|
|
316
321
|
return data
|
|
317
322
|
}
|
|
318
323
|
} catch (error) {
|
|
319
|
-
if (this._isCancelled(error)) throw
|
|
324
|
+
if (this._isCancelled(error)) throw this._cancelledError()
|
|
320
325
|
if (requestToken && error && typeof error === 'object') {
|
|
321
326
|
error.requestToken = requestToken
|
|
322
327
|
}
|
|
@@ -325,6 +330,9 @@ export default class Request {
|
|
|
325
330
|
this.errorHandler && this.errorHandler(error)
|
|
326
331
|
throw error
|
|
327
332
|
}
|
|
333
|
+
// 舊身分遲到的錯誤不進 errorHandler;目前沒 token(TTL 過期或已 CLEAR)時維持原路由,A204 等彈窗才不會被吞
|
|
334
|
+
const currentToken = this.getToken()
|
|
335
|
+
if (requestToken && currentToken && currentToken !== requestToken) throw error
|
|
328
336
|
if (error.code === 'ERR_998') {
|
|
329
337
|
throw error
|
|
330
338
|
}
|