mirror of
https://github.com/tenrok/axios.git
synced 2026-05-24 14:04:14 +03:00
Added errors to be displayed when the query parsing process itself fails. (#3961)
* Adding errors when the query parsing process fails * Updated error * Removed unused variables Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user