@jetthai/cuora 1.1.481-api.0 → 1.1.481-api.2
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 +13 -4
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,15 +321,19 @@ export default class Request {
|
|
|
316
321
|
return data
|
|
317
322
|
}
|
|
318
323
|
} catch (error) {
|
|
319
|
-
if (this._isCancelled(error)) throw
|
|
320
|
-
|
|
321
|
-
|
|
324
|
+
if (this._isCancelled(error)) throw this._cancelledError()
|
|
325
|
+
// 不可列舉:避免 Bearer token 隨 JSON.stringify/Sentry 序列化外洩,但 error.requestToken 仍可讀取
|
|
326
|
+
if (requestToken && error && typeof error === 'object' && Object.isExtensible(error)) {
|
|
327
|
+
Object.defineProperty(error, 'requestToken', { value: requestToken, enumerable: false, configurable: true })
|
|
322
328
|
}
|
|
323
329
|
if (error.code === 'ERR_F108') {
|
|
324
330
|
this.isBlocked = true
|
|
325
331
|
this.errorHandler && this.errorHandler(error)
|
|
326
332
|
throw error
|
|
327
333
|
}
|
|
334
|
+
// 舊身分遲到的錯誤不進 errorHandler;目前沒 token(TTL 過期或已 CLEAR)時維持原路由,A204 等彈窗才不會被吞
|
|
335
|
+
const currentToken = this.getToken()
|
|
336
|
+
if (requestToken && currentToken && currentToken !== requestToken) throw error
|
|
328
337
|
if (error.code === 'ERR_998') {
|
|
329
338
|
throw error
|
|
330
339
|
}
|