import { has } from 'lodash/fp' ; export interface AppError extends Error { body : { message : string ; } ; } export interface KibanaError extends AppError { body : { message : string ; statusCode : number ; } ; } export interface SecurityAppError extends AppError { body : { message : string ; status_code : number ; } ; } export const isKibanaError = ( error ) : error is KibanaError => has ( 'message' , error ) && has ( 'body.message' , error ) && has ( 'body.statusCode' , error ) ; export const isSecurityAppError = ( error ) : error is SecurityAppError => has ( 'message' , error ) && has ( 'body.message' , error ) && has ( 'body.status_code' , error ) ; export const isAppError = ( error ) : error is AppError => isKibanaError ( error ) || isSecurityAppError ( error ) ; export const isNotFoundError = ( error ) => ( isKibanaError ( error ) && error . body . statusCode === 404 ) || ( isSecurityAppError ( error ) && error . body . status_code === 404 ) ;