Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added errors to be displayed when the query parsing process itself fails. #3961

Merged
merged 6 commits into from Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/adapters/http.js
Expand Up @@ -138,6 +138,16 @@ module.exports = function httpAdapter(config) {
var isHttpsRequest = isHttps.test(protocol);
var agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;

try {
buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, '');
} catch (err) {
var customErr = new Error(err.message);
customErr.config = config;
customErr.url = config.url;
customErr.exists = true;
reject(customErr);
}

var options = {
path: buildURL(parsed.path, config.params, config.paramsSerializer).replace(/^\?/, ''),
method: config.method.toUpperCase(),
Expand Down
15 changes: 15 additions & 0 deletions test/unit/adapters/http.js
Expand Up @@ -492,6 +492,21 @@ describe('supports http with nodejs', function () {
});
});

it('should display error while parsing params', function (done) {
server = http.createServer(function () {

}).listen(4444, function () {
axios.get('http://localhost:4444/', {
params: {
errorParam: new Date(undefined),
},
}).catch(function (err) {
assert.deepEqual(err.exists, true)
done();
});
});
});

it('should support sockets', function (done) {
// Different sockets for win32 vs darwin/linux
var socketName = './test.sock';
Expand Down