Monday, 29 May 2017

Rethrow non mysql error when throwing error

I've written a simple function with a callback. It checks the callback data if an error variable is defined, and if it is throws a new error.

However, i get this error and the app crashes.

G:\WORK\cry\node_modules\node-querybuilder\node_modules\mysql\lib\protocol\Parser.js:77 throw err; // Rethrow non-MySQL errors

This is the function

user.complete_user_existence = function(type,userData){
        if(type == 0){
            //Add to db and cache
            data = {
                id : null,
                tid : userData.id,
                f_name : userData.first_name,
                l_name : userData.last_name,
                inv : 0,
                language : null,
            }
            user.dbc.add_db('usersz',data,function(err,response){
                if(err){
                    throw "An unexpected error occured! Please try again";
                }
            });
        }
        //Need to load to cache anyway

}



via Haider Ali

No comments:

Post a Comment