summaryrefslogtreecommitdiff
path: root/test/parallel/test-http2-util-nghttp2error.js
blob: 100ce2cb45993ba351eb895177bd971b55c2cb7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Flags: --expose-internals
'use strict';

const common = require('../common');
const { strictEqual } = require('assert');
const { NghttpError } = require('internal/http2/util');

common.expectsError(() => {
  const err = new NghttpError(-501);
  strictEqual(err.errno, -501);
  throw err;
}, {
  code: 'ERR_HTTP2_ERROR',
  type: NghttpError,
  message: 'Invalid argument'
});

// Should convert the NghttpError object to string properly
{
  const err = new NghttpError(401);
  strictEqual(err.toString(), 'Error [ERR_HTTP2_ERROR]: Unknown error code');
}