JSDoc: Namespace: error

# Namespace: error

## error

Source:
  - error.js, line 55

### Methods

#### (static) isError(val) → {boolean}

Check if |val| is an instance of the |Error| prototype.

Because error objects may originate from different globals, comparing the prototype of the left hand side with the prototype property from the right hand side, which is what |instanceof| does, will not work. If the LHS and RHS come from different globals, this check will always fail because the two objects will not have the same identity.

Therefore it is not safe to use |instanceof| in any multi-global situation, e.g. in content across multiple Window objects or anywhere in chrome scope.

This function also contains a special check if |val| is an XPCOM |nsIException| because they are special snowflakes and may indeed cause Firefox to crash if used with |instanceof|.

##### Parameters:

Name | Type | Description
--- | --- | ---
`val` | * | Any value that should be undergo the test for errorness.

Source:
  - error.js, line 79

##### Returns:

True if error, false otherwise.

Type
  boolean

#### (static) isWebDriverError()

Checks if obj is an object in the WebDriverError prototypal chain.

Source:
  - error.js, line 98

#### (static) report()

Unhandled error reporter. Dumps the error and its stacktrace to console, and reports error to the Browser Console.

Source:
  - error.js, line 128

#### (static) stringify()

Prettifies an instance of Error and its stacktrace to a string.

Source:
  - error.js, line 139

#### (static) wrap(err) → {WebDriverError}

Ensures error instance is a WebDriverError.

If the given error is already in the WebDriverError prototype chain, |err| is returned unmodified. If it is not, it is wrapped in UnknownError.

##### Parameters:

Name | Type | Description
--- | --- | ---
`err` | Error | Error to conditionally turn into a WebDriverError.

Source:
  - error.js, line 117

##### Returns:

If |err| is a WebDriverError, it is returned unmodified. Otherwise an UnknownError type is returned.

Type
  WebDriverError