How to use the isError function from util

Find comprehensive JavaScript util.isError code examples handpicked from public code repositorys.

232
233
234
235
236
237
  // true
```


<div id="isError" class="anchor"></div>
## util.isError(object)
fork icon21
star icon99
watch icon2

+ 3 other calls in file

341
342
343
344
345
346
347
348
349
350
// false (without 'new' returns a String)
util.isDate({});
// Returns: false
```

### util.isError(object)
<!-- YAML
added: v0.6.0
deprecated: v4.0.0
-->
fork icon0
star icon6
watch icon1

1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
if (shouldThrow && !actual) {
  fail(actual, expected, 'Missing expected exception' + message);
}

var userProvidedMessage = typeof message === 'string';
var isUnwantedException = !shouldThrow && util.isError(actual);
var isUnexpectedException = !shouldThrow && actual && !expected;

if ((isUnwantedException &&
    userProvidedMessage &&
fork icon0
star icon0
watch icon1

+ 2 other calls in file