Home App Docs Blog Github

Vue sdk error handling

Currently the error handling on the builder SDK is not catching any error,

When the API returns an error, it returns a string Error… - and in the sdk it then parses with JSON.parse - and it crashes the node process each time. As there is no real validation in the custom code, it is quite problematic for our front end people as when they do make a mistake, it ends up crashing the server.

 return new Promise(function (resolve, reject) {
            var module = url.indexOf('http:') === 0 ? serverOnlyRequire$1('http') : serverOnlyRequire$1('https');
            module
                .get(url, function (resp) {
                var data = '';
                // A chunk of data has been recieved.
                resp.on('data', function (chunk) {
                    data += chunk;
                });
                // The whole response has been received. Print out the result.
                resp.on('end', function () {
                    resolve(JSON.parse(data));
                });
            })
                .on('error', function (error) {
                reject(error);
            });
        });