Refactor error types to follow new file structure
Co-authored-by: Jared Scheib <jared.scheib@gmail.com>pull/10616/head
parent
61130535e5
commit
058af91e46
|
@ -73,7 +73,7 @@ import * as DashboardAPIs from 'src/types/apis/dashboard'
|
|||
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
||||
import * as AuthReducers from 'src/types/reducers/auth'
|
||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||
import * as ErrorActions from 'src/shared/actions/errors'
|
||||
import * as ErrorActions from 'src/types/actions/error'
|
||||
import {LocationAction} from 'react-router-redux'
|
||||
|
||||
export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = (
|
||||
|
|
|
@ -65,7 +65,7 @@ import * as AnnotationActions from 'src/shared/actions/annotations'
|
|||
import * as AppActions from 'src/shared/actions/app'
|
||||
import * as CellEditorOverlayActions from 'src/dashboards/actions/cellEditorOverlay'
|
||||
import * as DashboardActions from 'src/types/actions/dashboard'
|
||||
import * as ErrorActions from 'src/shared/actions/errors'
|
||||
import * as ErrorActions from 'src/types/actions/error'
|
||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||
|
||||
interface DashboardActions {
|
||||
|
|
|
@ -49,6 +49,7 @@ import {notify} from 'src/shared/actions/notifications'
|
|||
import 'src/style/chronograf.scss'
|
||||
|
||||
import {HEARTBEAT_INTERVAL} from 'src/shared/constants'
|
||||
import * as ErrorData from 'src/types/error'
|
||||
|
||||
const errorsQueue = []
|
||||
|
||||
|
@ -185,7 +186,13 @@ class Root extends PureComponent<{}, State> {
|
|||
if (typeof error === 'object') {
|
||||
dispatch(notify(error))
|
||||
} else {
|
||||
dispatch(errorThrown({status: 0, auth: null}, error, 'warning'))
|
||||
dispatch(
|
||||
errorThrown(
|
||||
{status: 0, auth: null},
|
||||
error,
|
||||
ErrorData.AlertType.Warning
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,35 +1,13 @@
|
|||
enum AlertType {
|
||||
'info',
|
||||
}
|
||||
import * as ErrorData from 'src/types/error'
|
||||
import * as ErrorActions from 'src/types/actions/error'
|
||||
|
||||
export type ErrorThrownActionCreator = (
|
||||
error: Error,
|
||||
altText?: string,
|
||||
alertType?: AlertType
|
||||
) => ErrorThrownAction
|
||||
|
||||
interface ErrorThrownAction {
|
||||
type: 'ERROR_THROWN'
|
||||
error: ErrorDescription
|
||||
altText?: string
|
||||
alertType?: AlertType
|
||||
}
|
||||
export const errorThrown = (
|
||||
error: ErrorDescription,
|
||||
error: ErrorData.ErrorDescription,
|
||||
altText?: string,
|
||||
alertType?: AlertType
|
||||
): ErrorThrownAction => ({
|
||||
alertType?: ErrorData.AlertType
|
||||
): ErrorActions.ErrorThrownAction => ({
|
||||
type: 'ERROR_THROWN',
|
||||
error,
|
||||
altText,
|
||||
alertType,
|
||||
})
|
||||
|
||||
interface ErrorDescription {
|
||||
status: number
|
||||
auth: {
|
||||
links: {
|
||||
me: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import {Source} from 'src/types'
|
|||
import * as DashboardData from 'src/types/dashboard'
|
||||
import * as QueryData from 'src/types/query'
|
||||
import * as TempVarData from 'src/types/tempVars'
|
||||
import * as ErrorActions from 'src/shared/actions/errors'
|
||||
import * as ErrorActions from 'src/types/actions/error'
|
||||
import * as NotificationActions from 'src/shared/actions/notifications'
|
||||
import * as DashboardReducers from 'src/types/reducers/dashboard'
|
||||
import {Location} from 'history'
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import * as ErrorData from 'src/types/error'
|
||||
|
||||
export type ErrorThrownActionCreator = (
|
||||
error: ErrorData.ErrorDescription,
|
||||
altText?: string,
|
||||
alertType?: ErrorData.AlertType
|
||||
) => ErrorThrownAction
|
||||
|
||||
export interface ErrorThrownAction {
|
||||
type: 'ERROR_THROWN'
|
||||
error: ErrorData.ErrorDescription
|
||||
altText?: string
|
||||
alertType?: ErrorData.AlertType
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
export interface ErrorDescription {
|
||||
status: number
|
||||
auth: {
|
||||
links: {
|
||||
me: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export enum AlertType {
|
||||
Info = 'info',
|
||||
Warning = 'warning',
|
||||
}
|
Loading…
Reference in New Issue