Send error via mail when not directly accessable

I have a case where i am trying to debug my code but i am not able to directly access that page to see if there’s an error as well as the usual informations shown when seeing it.

is this possible to trigger somehow?

maybe hijack whoops that comes with kirby? and write to log using a custom handler?