From f8703827099919b3805bc9686e963f003e516439 Mon Sep 17 00:00:00 2001 From: nlf Date: Thu, 3 Mar 2022 10:14:44 -0800 Subject: [PATCH] fix: add code property to unsupported proxy url error --- lib/agent.js | 1 + test/agent.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/agent.js b/lib/agent.js index cc1d388..d28a31b 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -198,6 +198,7 @@ function getProxy (proxyUrl, opts, isHttps) { throw Object.assign( new Error(`unsupported proxy protocol: '${proxyUrl.protocol}'`), { + code: 'EUNSUPPORTEDPROXY', url: proxyUrl.href, } ) diff --git a/test/agent.js b/test/agent.js index 9f40bef..522a6c7 100644 --- a/test/agent.js +++ b/test/agent.js @@ -353,6 +353,7 @@ t.test('get proxy agent', async t => { t.throws(() => getProxy(new url.URL('gopher://proxy.local'), OPTS, false), { message: 'unsupported proxy protocol: \'gopher:\'', + code: 'EUNSUPPORTEDPROXY', url: 'gopher://proxy.local', }) })