mariadb-corporation / mariadb-connector-nodejs

MariaDB Connector/Node.js is used to connect applications developed on Node.js to MariaDB and MySQL databases. MariaDB Connector/Node.js is LGPL licensed.
GNU Lesser General Public License v2.1
368 stars 91 forks source link

SIGNAL SET MESSAGE_TEXT from stored procedure does not get pass on #152

Closed outbackStack closed 3 years ago

outbackStack commented 3 years ago
CREATE PROCEDURE test_error(x INT)
BEGIN
   IF x = 1 THEN
      SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'not working';
   END IF;
END;

then using node

const mariadb = require('mariadb');
const pool = mariadb.createPool({host: process.env.DB_HOST, user: process.env.DB_USER, connectionLimit: 5});

async function asyncFunction() {
  let conn;
  try {
    conn = await pool.getConnection();
    const res = await conn.query("CALL test_error(1)");

  } catch (err) {
    console.log(err)
  }
}

console.log(error) only print out the following:

  fatal: false,
  errno: 1644,
  sqlState: '45000',
  code: 'ER_SIGNAL_EXCEPTION'

How could I access the MESSAGE_TEXT' variable from catch error?