Precond provides a set of functions to verify arguments and state correctness
It lets you rewrite constructs like the following
if (!this.isConnected) { throw new Error('Client should be connected before calling X.');}
into a more compact and declarative check bellow.
precond.checkState(this.isConnected, 'Client should be ...');
Note that even though the throw statement is wrapped in a function, the call
stack will still start from the calling function. So the previous examples would
both produce the same stack trace.
All arguments after the message will be used to format the actual error
message that will be thrown.
formatArgs: arguments to be substituted into the message template
Ensures that value is defined (could be null). Throws an
IllegalArgumentError if value is undefined. Returns the value of
the value that was validated.
value: the value that is required to be defined and not null
messageFormat: error message format template
formatArgs: arguments to be substituted into the message template
Ensures that value is defined and not null. Throws an
IllegalArgumentError if value is undefined or null. Returns the value of
the value that was validated.
formatArgs: arguments to be substituted into the message template
Ensures that value is a string or a String object. Throws an
IllegalArgumentError if value isn't a string. Returns the value of
the value that was validated.