Builds a typed error whose stack starts at the caller, not inside this helper.
The only reason to prefer this over new ValidationError(...): captureStackTrace elides
this frame, so the top of the stack is the code that decided to fail. Without it, every
error built through a factory points at the factory.
Parameters
ErrorClass: ErrorClassConstructor
Constructor to instantiate.
message: string
Error message.
context: ErrorContext = {}
Structured context attached to the instance. Defaults to {}.
Builds a typed error whose stack starts at the caller, not inside this helper.
The only reason to prefer this over
new ValidationError(...):captureStackTraceelides this frame, so the top of the stack is the code that decided to fail. Without it, every error built through a factory points at the factory.