Is there way to automate Snack Bar text using Protractor?

I’m trying by using bellow sample code but is not working properly, can you know anyone kindly suggest way or what are the changers to do.

enter code here   getText: async function () {  return await new Promise(async function (resolve, reject) { return await protractor.element(protractor.by.css('simple-snack-bar>span,.mat-simple-snackbar > span')).isPresent().then(async (isPresent) => {if (isPresent) {return await protractor.element(protractor.by.css('simple-snack-bar>span,.mat-simple-snackbar > span')).getText().then(async (snackBarText) => { resolve(snackBarText); }).catch(() => { return false; })}else {reject(isPresent);return false;}}}).catch(() => { return false; })}).catch((error) => {if (error.name === 'StaleElementReferenceError') { return false; }})}