(jqxhrOrError, errorEventName)
| 361 | } |
| 362 | |
| 363 | onSubscriptionError (jqxhrOrError, errorEventName) { |
| 364 | let jqxhr = null |
| 365 | let error = null |
| 366 | let message = '' |
| 367 | if (jqxhrOrError instanceof Error) { |
| 368 | error = jqxhrOrError |
| 369 | console.error(error.stack); |
| 370 | ({ |
| 371 | message |
| 372 | } = error) |
| 373 | } else { |
| 374 | // jqxhr |
| 375 | jqxhr = jqxhrOrError |
| 376 | message = `${jqxhr.status}: ${(jqxhr.responseJSON != null ? jqxhr.responseJSON.message : undefined) || jqxhr.responseText}` |
| 377 | } |
| 378 | if (application.tracker != null) { |
| 379 | application.tracker.trackEvent(errorEventName, { status: message, value: this.purchasedAmount }) |
| 380 | } |
| 381 | if ((jqxhr != null ? jqxhr.status : undefined) === 402) { |
| 382 | this.state = 'declined' |
| 383 | } else if (__guard__(jqxhr != null ? jqxhr.responseJSON : undefined, x => x.i18n)) { |
| 384 | this.state = 'error' |
| 385 | this.stateMessage = $.i18n.t(jqxhr.responseJSON.i18n) |
| 386 | } else { |
| 387 | this.state = 'unknown_error' |
| 388 | this.stateMessage = $.i18n.t('loading_error.unknown') |
| 389 | } |
| 390 | return this.render() |
| 391 | } |
| 392 | |
| 393 | onHidden () { |
| 394 | super.onHidden() |
no test coverage detected