brianschardt / node_rest_api_mysql

MIT License
248 stars 140 forks source link

doesn't catch errors when registering with same user data. #3

Closed darvesh closed 6 years ago

darvesh commented 6 years ago
Executing (default): INSERT INTO `Users` (`id`,`first`,`last`,`email`,`phone`,`password`,`createdAt`,`updatedAt`) VALUES (DEFAULT,'fn','sn','d@a.com','1234567891','$2a$10$79CyNDx0W8Bwyn6IG.ZleeMNXBo/s4Y.FIvoQCPxu0dY6IEfYipMy','2018-02-25 08:44:25','2018-02-25 08:44:25');
/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/sequelize/lib/dialects/mysql/query.js:186
        const uniqueKey = this.model && this.model.uniqueKeys[match[2]];
                                                                   ^

TypeError: Cannot read property '2' of null
    at Query.formatError (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/sequelize/lib/dialects/mysql/query.js:186:68)
    at Query.connection.query [as onResult] (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/sequelize/lib/dialects/mysql/query.js:55:23)
    at Query.Command.execute (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/mysql2/lib/commands/command.js:30:12)
    at Connection.handlePacket (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/mysql2/lib/connection.js:515:28)
    at PacketParser.onPacket (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/mysql2/lib/connection.js:94:16)
    at PacketParser.executeStart (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/mysql2/lib/packet_parser.js:77:14)
    at Socket.<anonymous> (/home/solooo7/Documents/MASTER/TEST/node_rest_api_mysql/node_modules/mysql2/lib/connection.js:102:29)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server@0.0.0 start: `node ./bin/www`
npm 
ERR! Exit status 1

It doesn't catch errors when I register with same user details. Any idea why?

darvesh commented 6 years ago

The error shows only when I try this in localhost(mysql).