PHP 8.2.30
Preview: err.js Size: 1.50 KB
/home/byroehnu/.trash/node_modules11/object-inspect/test/err.js

var test = require('tape');
var ErrorWithCause = require('error-cause/Error');

var inspect = require('../');

test('type error', function (t) {
    t.plan(1);
    var aerr = new TypeError();
    aerr.foo = 555;
    aerr.bar = [1, 2, 3];

    var berr = new TypeError('tuv');
    berr.baz = 555;

    var cerr = new SyntaxError();
    cerr.message = 'whoa';
    cerr['a-b'] = 5;

    var withCause = new ErrorWithCause('foo', { cause: 'bar' });
    var withCausePlus = new ErrorWithCause('foo', { cause: 'bar' });
    withCausePlus.foo = 'bar';
    var withUndefinedCause = new ErrorWithCause('foo', { cause: undefined });
    var withEnumerableCause = new Error('foo');
    withEnumerableCause.cause = 'bar';

    var obj = [
        new TypeError(),
        new TypeError('xxx'),
        aerr,
        berr,
        cerr,
        withCause,
        withCausePlus,
        withUndefinedCause,
        withEnumerableCause
    ];
    t.equal(inspect(obj), '[ ' + [
        '[TypeError]',
        '[TypeError: xxx]',
        '{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
        '{ [TypeError: tuv] baz: 555 }',
        '{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }',
        'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: \'bar\' }',
        '{ [Error: foo] ' + ('cause' in Error.prototype ? '' : '[cause]: \'bar\', ') + 'foo: \'bar\' }',
        'cause' in Error.prototype ? '[Error: foo]' : '{ [Error: foo] [cause]: undefined }',
        '{ [Error: foo] cause: \'bar\' }'
    ].join(', ') + ' ]');
});

Directory Contents

Dirs: 1 × Files: 18

Name Size Perms Modified Actions
browser DIR
- drwxr-xr-x 2026-02-03 15:06:16
Edit Download
2.03 KB lrw-r--r-- 2026-02-03 15:06:14
Edit Download
451 B lrw-r--r-- 2026-02-03 15:06:16
Edit Download
400 B lrw-r--r-- 2026-02-03 15:06:16
Edit Download
1.54 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.50 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
683 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
2.17 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
372 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
514 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
255 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
6.48 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
4.83 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
268 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
2.26 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.49 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.51 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
302 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
8.21 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).