Prioritizing errors - creating an escalation system

I’m building an error-escalation system, in order to do so I will need to prioritize errors that are being thrown “organically” or so to speak, not errors made by users (as in error(_)).
I want all errors that break scripts completely to be critical, so this does not include errors thrown from events/threads.
How would you go around doing this?

I thought making some wrappers for certain scripts / sanity checks (though the latter don’t seem to be efficient, or maybe IDK how to make them efficient?).
Would really appreciate your thoughts on this.
Thanks in advance!!

EDIT: If it’s not clear: the motivation is to create a mailing system for critical errors so not to rush to the logs on weekends/fix issues at minimum time.

ScriptContext.Error? I don’t get what you want to achieve?

I already work with GA, so I have full logs.
Trying to prioritize errors with a mailing system, so to know if the error is important → send mail. I don’t want to look at GA on weekends.

I’m pretty sure there isn’t a way. You could use warn instead of error in your scripts if that were practical, or you could write a custom error override function which throws an error but also adds a flag so it can be identified as non-organic.

Oh I know there is no way, that’s why I’m creating a system for it. But not sure what is the best way. Sanity checks (heartbeat samples every X time) and script wrappers are what I’m thinking to do.