Namespace goog.asserts
code »Classes
|
Global Functions
The default error handler.
Parameters |
---|
|
Checks if the condition evaluates to true if goog.asserts.ENABLE_ASSERTS is
true.
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.assertArray ( value, opt_message, var_args ) ⇒ !Array
Checks if the value is an Array if goog.asserts.ENABLE_ASSERTS is true.
!Array
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.assertBoolean ( value, opt_message, var_args ) ⇒ boolean
Checks if the value is a boolean if goog.asserts.ENABLE_ASSERTS is true.
boolean
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.assertElement ( value, opt_message, var_args ) ⇒ !Element
Checks if the value is a DOM Element if goog.asserts.ENABLE_ASSERTS is true.
!Element
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.assertFunction ( value, opt_message, var_args ) ⇒ !Function
Checks if the value is a function if goog.asserts.ENABLE_ASSERTS is true.
!Function
Parameters |
---|
|
Returns |
|
Throws |
|
Checks if the value is an instance of the user-defined type if
goog.asserts.ENABLE_ASSERTS is true.
The compiler may tighten the type returned by this function.
Parameters |
---|
|
Throws |
|
code »goog.asserts.assertNumber ( value, opt_message, var_args ) ⇒ number
Checks if the value is a number if goog.asserts.ENABLE_ASSERTS is true.
number
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.assertObject ( value, opt_message, var_args ) ⇒ !Object
Checks if the value is an Object if goog.asserts.ENABLE_ASSERTS is true.
!Object
Parameters |
---|
|
Returns |
|
Throws |
|
Checks that no enumerable keys are present in Object.prototype. Such keys
would break most code that use for (var ... in ...)
loops.
for (var ... in ...)
loops.code »goog.asserts.assertString ( value, opt_message, var_args ) ⇒ string
Checks if the value is a string if goog.asserts.ENABLE_ASSERTS is true.
string
Parameters |
---|
|
Returns |
|
Throws |
|
code »goog.asserts.doAssertFailure_ ( defaultMessage, defaultArgs, givenMessage, givenArgs )Throws an exception with the given message and "Assertion failed" prefixed
onto it.
Parameters |
---|
Throws |
|
The handler responsible for throwing or logging assertion errors.
code »goog.asserts.fail ( opt_message, var_args )Fails if goog.asserts.ENABLE_ASSERTS is true. This function is useful in case
when we want to add a check in the unreachable area like switch-case
statement:
switch(type) {
case FOO: doSomething(); break;
case BAR: doSomethingElse(); break;
default: goog.assert.fail('Unrecognized type: ' + type);
// We have only 2 types - "default:" section is unreachable code.
}
Parameters |
---|
|
Throws |
|
code »goog.asserts.setErrorHandler ( errorHandler )Sets a custom error handler that can be used to customize the behavior of
assertion failures, for example by turning all assertion failures into log
messages.
Parameters |
---|
|