Page 1 of 1
(AS1) - How to get MySQL error message?
Posted: 31 Aug 2011, 14:00
by Rashomon
I have an AS1 extension. It updates the database with executeCommand and checks for success like so:
Code: Select all
var success = dbase.executeCommand(sql)
if (success) {
} else {
}
How can I get more details on the failure, though? How can I get the actual error message so I can pass the details back to the user? I tried to use a try/catch block, but try/catch is not available in AS1. It's hard to find any AS1 docs, these days, so I was hoping you guys would know.
Posted: 31 Aug 2011, 14:28
by rjgtav
Hi. I think that's only possible only with a try/catch statement.
Something like:
Code: Select all
try{
dbase.executeCommand(sql)
}catch(e){
trace("Error while executing command: "+e)
}
Not sure if this works and can't test now
Posted: 31 Aug 2011, 15:15
by Rashomon
Yeah. That's what I tried, earlier (my reference to the "try/catch" block). Unfortunately, I kept getting errors when I started the server.
I was using "catch(e:Error)". When I use "catch(e)", the server will start. The code will also process a successful query. However, the catch never runs. I do, however, see the error message in the dump, but it's (apparently from the system, and not from the catch:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'MyValue' for key 'my_field_UNIQUE'
Posted: 31 Aug 2011, 16:01
by rjgtav
Hum... it looks like then this is not possible with AS Extensions. Maybe with Java Extensions is...
Posted: 01 Sep 2011, 04:34
by BigFIsh
It's not a good idea to send the error message to the client - it just opens a door for sql injection / hack. So that's why the error is only logged in your logs.