Repository: sindresorhus/got (ts)

Issue:
Add protocol to error messages
https://github.com/sindresorhus/got/blob/master/index.js#L339 has a bunch of request settings copied into the error object. The protocol would also be helpful.

Pull request description:
Add protocol to stdError
Adds the protocol to the stdError object got uses for all its errors.
Closes #249.

(These are _so_ much fun to do. If only my lunch break was longer.)

Patch:
diff --git a/index.js b/index.js
index 31a64dd..29e7189 100644
--- a/index.js
+++ b/index.js
@@ -334,7 +334,8 @@ function stdError(error, opts) {
 		host: opts.host,
 		hostname: opts.hostname,
 		method: opts.method,
-		path: opts.path
+		path: opts.path,
+		protocol: opts.protocol
 	});
 }
 


Test patch:
diff --git a/test/error.js b/test/error.js
index c8ad385..40306d2 100644
--- a/test/error.js
+++ b/test/error.js
@@ -27,6 +27,7 @@ test('properties', async t => {
 		t.is(err.message, 'Response code 404 (Not Found)');
 		t.is(err.host, `${s.host}:${s.port}`);
 		t.is(err.method, 'GET');
+		t.is(err.protocol, 'http:');
 	}
 });