While I agree with others that acting on the error message and simply looking into the query source file is the most useful way to do that under most circumstances, you can have MySQL/MariaDB log all queries using
MariaDB Audit Plugin and then grep the log file for failed queries which will include a distinct return code identifying those with errors.