import _ from 'lodash' ; const getRootCause = ( err ) => _ . get ( err , 'resp.error.root_cause' ) ; param { Error | String } err returns { string } export const formatOpenSearchMsg = ( err ) => { const rootCause = getRootCause ( err ) ; if ( ! Array . isArray ( rootCause ) ) { return ; } return rootCause . map ( ( cause ) => cause . reason ) . join ( '\n' ) ; } ;