Good morning, I need handle exceptions when a database can't connect,
When that ocurre, the traceback is:
Traceback (most recent call last):
File "/var/www/web2py/gluon/restricted.py", line 227, in restricted
exec ccode in environment
File "/var/www/web2py/applications/servicios/models/00db.py"
<http://localhost:8090/admin/default/edit/servicios/models/00db.py>, line 23,
in <module>
'db.pool_size', cast=int), check_reserved=['all'])
File "/var/www/web2py/gluon/packages/dal/pydal/base.py", line 174, in __call__
obj = super(MetaDAL, cls).__call__(*args, **kwargs)
File "/var/www/web2py/gluon/packages/dal/pydal/base.py", line 459, in __init__
raise RuntimeError("Failure to connect, tried %d times:\n%s" % (attempts,
tb))
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
File "/var/www/web2py/gluon/packages/dal/pydal/base.py", line 437, in __init__
self._adapter = ADAPTERS[self._dbname](**kwargs)
File "/var/www/web2py/gluon/packages/dal/pydal/adapters/base.py", line 57, in
__call__
obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
File "/var/www/web2py/gluon/packages/dal/pydal/adapters/mysql.py", line 132,
in __init__
if do_connect: self.reconnect()
File "/var/www/web2py/gluon/packages/dal/pydal/connection.py", line 125, in
reconnect
self.connection = f()
File "/var/www/web2py/gluon/packages/dal/pydal/adapters/mysql.py", line 130,
in connector
return self.driver.connect(**driver_args)
File "/var/www/web2py/gluon/contrib/pymysql/__init__.py", line 93, in Connect
return Connection(*args, **kwargs)
File "/var/www/web2py/gluon/contrib/pymysql/connections.py", line 575, in
__init__
self._connect()
File "/var/www/web2py/gluon/contrib/pymysql/connections.py", line 741, in
_connect
self._request_authentication()
File "/var/www/web2py/gluon/contrib/pymysql/connections.py", line 796, in
_request_authentication
self._send_authentication()
File "/var/www/web2py/gluon/contrib/pymysql/connections.py", line 845, in
_send_authentication
auth_packet.check_error()
File "/var/www/web2py/gluon/contrib/pymysql/connections.py", line 341, in
check_error
raise_mysql_exception(self.__data)
File "/var/www/web2py/gluon/contrib/pymysql/err.py", line 142, in
raise_mysql_exception
_check_mysql_exception(errinfo)
File "/var/www/web2py/gluon/contrib/pymysql/err.py", line 135, in
_check_mysql_exception
raise errorclass, (errno,errorvalue)
OperationalError: (1045, u"Access denied for user 'admin'@'172.17.0.2' (using
password: YES)")
try:
someCode()
except RuntimeError:
return 'errors'
but that don't work, what is the method to catch this exceptions?
thanks very much
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.