[Issue27234] Add helper method to log error message with cleanup actions