Description
throw new Error("msg")
is nice, because at runtime it will output a message to the console.
ERROR("msg")
is useful for compile errors.
However, sometimes changes happen to a code base, and also we want interop with TS tooling (f.e. without using throw
type narrowing does not happen, so we may write throw ERROR(...)
to appease both TypeScript and AS at compile time). Due to changes in the code base, what was previously a compile time error can become a runtime error.
So as a convention, I've using throw ERROR(...)
alot to appease TS tooling, attempt to catch errors at compile time, but also have something that actually works at runtime in case when that happens do to code refactorings.
Currently, when an AS module reaches an ERROR("message")
at runtime, no message is logged to console. The error looks identical to new Error("message")
, just without the message part included.
This is a feature idea to make it so that ERROR()
causes a message to be logged if reached at runtime, just the same as if we had written new Error
.