Closed quakef4 closed 3 years ago
Hi,
Not directly, no, but the modification isn’t difficult. You could simply write a special handler as part of parse_error_packet(), add code to execute_query(), or add a function to return the error number (best solution).
Dr. Bell
Hint (warning: not tested):
--- /Users/cbell/source/MySQL_Connector_Arduino/src/MySQL_Cursor.h 2020-09-03 15:37:28.000000000 -0400 +++ ./MySQL_Cursor.h 2021-01-04 14:04:20.000000000 -0500 @@ -79,6 +79,7 @@ void show_results(); int get_rows_affected() { return rows_affected; } int get_last_insert_id() { return last_insert_id; }
int get_error() { return conn->read_int(5, 2); }
private:
And in your sketch, do something like this (again, not tested):
if (!cur.execute(query)) { If (cur.get_error() == 75) { Serial.println(“My custom error. “); } else { Serial.print(“ERROR: Wonkification in progress. Error code=“); Serial.println(cur.get_error()); } }
On Jan 4, 2021, at 1:31 PM, quakef4 notifications@github.com wrote:
Hello, I would need to memorize the type of error within a variable: Example this: Error: 75 = Deadlock found when trying to get lock; try restarting transaction. in this case, I would need to memorize the number 75 inside a variable.
Is this possible without making changes to the library?
Thanks in advance!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYBOMZJZYVY7JYNLOXLSYICOZANCNFSM4VTMKLXQ.
Yeah! it work fine!
Only correct little thing on arduino sketch:
->
instead of .
Serial.println(cur->get_error());
Would it be possible to add it as a modification?
Detecting the error allows you to understand if the query was sent and acquired successfully.
Correct me if I'm wrong
On my list, yes. :)
On Mon, Jan 4, 2021 at 14:40 quakef4 notifications@github.com wrote:
Reopened #163 https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/163.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/163#event-4166428685, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB6SHYDGCYH5KBUM45UUBQTSYIKUTANCNFSM4VTMKLXQ .
Thanks! To make good!
Hello, I would need to memorize the type of error within a variable: Example this:
Error: 75 = Deadlock found when trying to get lock; try restarting transaction.
in this case, I would need to memorize the number 75 inside a variable.Is this possible without making changes to the library?
Thanks in advance!