Skip to content

Commit

Permalink
Fix bug with AbortError check
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Feb 25, 2021
1 parent a05b837 commit cbdd68a
Show file tree
Hide file tree
Showing 21 changed files with 22 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getFieldsByIssueType } from './api';
import { Fields } from './types';
Expand Down Expand Up @@ -70,7 +69,7 @@ export const useGetFieldsByIssueType = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.FIELDS_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const useGetIssueTypes = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error.name === 'AbortError')) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.ISSUE_TYPES_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { isEmpty, debounce } from 'lodash/fp';
import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getIssues } from './api';
import { Issues } from './types';
Expand Down Expand Up @@ -71,7 +70,7 @@ export const useGetIssues = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.ISSUES_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getIssue } from './api';
import { Issue } from './types';
Expand Down Expand Up @@ -69,7 +68,7 @@ export const useGetSingleIssue = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.GET_ISSUE_API_ERROR(id),
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getIncidentTypes } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -68,7 +67,7 @@ export const useGetIncidentTypes = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.INCIDENT_TYPES_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getSeverity } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -65,7 +64,7 @@ export const useGetSeverity = ({ http, toastNotifications, connector }: Props):
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.SEVERITY_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useState, useEffect, useRef } from 'react';
import { HttpSetup, ToastsApi } from 'kibana/public';
import { AbortError } from '../../../../../../../../src/plugins/kibana_utils/common';
import { ActionConnector } from '../../../containers/types';
import { getChoices } from './api';
import { Choice } from './types';
Expand Down Expand Up @@ -74,7 +73,7 @@ export const useGetChoices = ({
} catch (error) {
if (!didCancel.current) {
setIsLoading(false);
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
toastNotifications.addDanger({
title: i18n.CHOICES_API_ERROR,
text: error.message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useCallback, useReducer, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { CaseStatuses } from '../../../../case/common/api';
import {
displaySuccessToast,
Expand Down Expand Up @@ -117,7 +116,7 @@ export const useUpdateCases = (): UseUpdateCases => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useCallback, useReducer, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import {
displaySuccessToast,
errorToToaster,
Expand Down Expand Up @@ -106,7 +105,7 @@ export const useDeleteCases = (): UseDeleteCase => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_DELETING,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useCallback, useEffect, useState, useRef } from 'react';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { getActionLicense } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -54,7 +53,7 @@ export const useGetActionLicense = (): ActionLicenseState => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { useEffect, useReducer, useCallback, useRef } from 'react';
import { CaseStatuses, CaseType } from '../../../../case/common/api';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { Case } from './types';
import * as i18n from './translations';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
Expand Down Expand Up @@ -119,7 +118,7 @@ export const useGetCase = (caseId: string, subCaseId?: string): UseGetCase => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { isEmpty, uniqBy } from 'lodash/fp';
import { useCallback, useEffect, useState, useRef } from 'react';
import deepEqual from 'fast-deep-equal';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { CaseFullExternalService } from '../../../../case/common/api/cases';
import { getCaseUserActions, getSubCaseUserActions } from './api';
Expand Down Expand Up @@ -288,7 +287,7 @@ export const useGetCaseUserActions = (
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useCallback, useEffect, useReducer, useRef } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { CaseStatuses } from '../../../../case/common/api';
import { DEFAULT_TABLE_ACTIVE_PAGE, DEFAULT_TABLE_LIMIT } from './constants';
import { AllCases, SortFieldCase, FilterOptions, QueryParams, Case, UpdateByKey } from './types';
Expand Down Expand Up @@ -178,7 +177,7 @@ export const useGetCases = (initialQueryParams?: QueryParams): UseGetCases => {
}
} catch (error) {
if (!didCancelFetchCases.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down Expand Up @@ -214,7 +213,7 @@ export const useGetCases = (initialQueryParams?: QueryParams): UseGetCases => {
}
} catch (error) {
if (!didCancelUpdateCases.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({ title: i18n.ERROR_TITLE, error, dispatchToaster });
}
dispatch({ type: 'FETCH_FAILURE', payload: 'caseUpdate' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useCallback, useEffect, useState, useRef } from 'react';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { getCasesStatus } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -57,7 +56,7 @@ export const useGetCasesStatus = (): UseGetCasesStatus => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { useCallback, useEffect, useState, useRef } from 'react';
import { isEmpty } from 'lodash/fp';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { User } from '../../../../case/common/api';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { getReporters } from './api';
Expand Down Expand Up @@ -64,7 +63,7 @@ export const useGetReporters = (): UseGetReporters => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useEffect, useReducer, useRef, useCallback } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { getTags } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -76,7 +75,7 @@ export const useGetTags = (): UseGetTags => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useReducer, useCallback, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { CasePostRequest } from '../../../../case/common/api';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { postCase } from './api';
Expand Down Expand Up @@ -69,7 +68,7 @@ export const usePostCase = (): UsePostCase => {
return response;
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useReducer, useCallback, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { CommentRequest } from '../../../../case/common/api';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';

Expand Down Expand Up @@ -79,7 +78,7 @@ export const usePostComment = (): UsePostComment => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useReducer, useCallback, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { CaseConnector } from '../../../../case/common/api';
import {
errorToToaster,
Expand Down Expand Up @@ -91,7 +90,7 @@ export const usePostPushToService = (): UsePostPushToService => {
return response;
} catch (error) {
if (!cancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { useReducer, useCallback, useRef, useEffect } from 'react';

import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';

import { patchCase, patchSubCase } from './api';
Expand Down Expand Up @@ -124,7 +123,7 @@ export const useUpdateCase = ({
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { useReducer, useCallback, useRef, useEffect } from 'react';
import { AbortError } from '../../../../../../src/plugins/kibana_utils/common';
import { errorToToaster, useStateToaster } from '../../common/components/toasters';
import { patchComment } from './api';
import * as i18n from './translations';
Expand Down Expand Up @@ -106,7 +105,7 @@ export const useUpdateComment = (): UseUpdateComment => {
}
} catch (error) {
if (!didCancel.current) {
if (!(error instanceof AbortError)) {
if (error.name !== 'AbortError') {
errorToToaster({
title: i18n.ERROR_TITLE,
error: error.body && error.body.message ? new Error(error.body.message) : error,
Expand Down

0 comments on commit cbdd68a

Please sign in to comment.