Automation still runs - Can you capture a failure? [Payload Too Large (error code: 40005)[

I’m using the Discord Integration but run into a slight issue with the below error.
90% of the time the files are sent through, however, some times they fail (because they’re too large)

When it does fail, the only way I’m aware is via this log event…

Communication error: 413 Payload Too Large (error code: 40005): Request entity too large

image

Is there anything I can use to capture the error and send that as a message?
Or anyway to highlight that the event didn’t fully work?

I’ve been reading into System Log and curious if I could do anything from there, or is it ‘write’ only?

For example, the trigger will be if this is written to the logs…

Communication error: 413 Payload Too Large (error code: 40005): Request entity too large

Looks like these two post below is the way forward.

  1. Manually enable the system_log_event
  2. Use the below automation as an example
alias: Send notification on error
trigger:
  - platform: event
    event_type: system_log_event
action:
  - service: persistent_notification.create
    data:
      title: Error occurred
      message: An error occurred in Home Assistant. Have a look at the log.