import { i18n } from '@osd/i18n' ; import { IHttpResponse } from 'angular' ; export type AngularHttpError = IHttpResponse < { message : string ; } > ; export function isAngularHttpError ( error ) { return ( error && typeof error . status === 'number' && typeof error . statusText === 'string' && error . data && typeof error . data . message === 'string' ) ; } export function formatAngularHttpError ( error ) { if ( error . status === - 1 ) { return i18n . translate ( 'opensearch_dashboards_legacy.notify.fatalError.unavailableServerErrorMessage' , { defaultMessage : 'An HTTP request has failed to connect. ' + 'Please check if the OpenSearch Dashboards server is running and that your browser has a working connection, ' + 'or contact your system administrator.' , } ) ; } return i18n . translate ( 'opensearch_dashboards_legacy.notify.fatalError.errorStatusMessage' , { defaultMessage : 'Error {errStatus} {errStatusText}: {errMessage}' , values : { errStatus : error . status , errStatusText : error . statusText , errMessage : error . data . message , } , } ) ; }