LISTSERV mailing list manager LISTSERV 16.5

Help for QSERV-L Archives


QSERV-L Archives

QSERV-L Archives


QSERV-L@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

QSERV-L Home

QSERV-L Home

QSERV-L  September 2015

QSERV-L September 2015

Subject:

Re: user error handler in wmgr

From:

"Van Klaveren, Brian N." <[log in to unmask]>

Reply-To:

General discussion for qserv (LSST prototype baseline catalog)

Date:

Wed, 9 Sep 2015 18:41:09 +0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (99 lines)

That's probably your problem. Internally, the decorator is performing isinstance(exc, excType) basically where excType is sqlalchemyExc and that's actually the python module sqlalchemy.exc, which, is not an exception type.

If you want to catch all SQLAlchemy errors, you actually want to do:

from sqlalchemy.exc import SQLAlchemyError

...with the following decorator:


@dbService.errorhandler(SQLAlchemyError)


Brian



> On Sep 9, 2015, at 11:29 AM, Becla, Jacek <[log in to unmask]> wrote:
> 
> from sqlalchemy import exc as sqlalchemyExc
> 
> see
> 
> https://github.com/lsst/qserv/blob/tickets/DM-2558/core/modules/wmgr/python/dbMgr.py
> 
> 
> 
> On 09/09/2015 10:27 AM, Van Klaveren, Brian N. wrote:
>> What is sqlalchemyExc?
>> 
>> Brian
>> 
>> 
>>> On Sep 9, 2015, at 9:49 AM, Becla, Jacek <[log in to unmask]> wrote:
>>> 
>>> Andy (and Brian?)
>>> 
>>> I don't know if that can easily be improved... Here is what I typically get when I introduce a problem in wmgr:
>>> 
>>> Traceback (most recent call last):
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
>>>    response = self.full_dispatch_request()
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
>>>    rv = self.handle_user_exception(e)
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1378, in handle_user_exception
>>>    if isinstance(e, typecheck):
>>> TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
>>> 2015-09-09 11:37:43,574 [PID:4849] [INFO] (_log() at _internal.py:87) werkzeug: 127.0.0.1 - - [09/Sep/2015 11:37:43] "POST /dbs HTTP/1.1" 500 -
>>> 
>>> 
>>> to get a sensible stack trace that is actually useful, I end up
>>> commenting out:
>>> 
>>> [log in to unmask](DbException)
>>> [log in to unmask](sqlalchemyExc)
>>> [log in to unmask](MySQLdb.Error)
>>> [log in to unmask](MySQLdb.Warning)
>>> #def dbExceptionHandler(error):
>>> #    """ All leaked database-related exceptions generate 500 error """
>>> #    return errorResponse(500, error.__class__.__name__, str(error))
>>> 
>>> 
>>> This is the error I would get if errorhandler code would be
>>> commented out:
>>> 
>>> 
>>> Traceback (most recent call last):
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
>>>    response = self.full_dispatch_request()
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
>>>    rv = self.handle_user_exception(e)
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
>>>    reraise(exc_type, exc_value, tb)
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
>>>    rv = self.dispatch_request()
>>>  File "/home/becla/stack/Linux64/flask/0.10.1+11/lib/python/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
>>>    return self.view_functions[rule.endpoint](**req.view_args)
>>>  File "/usr/local/home/becla/stack/repos/qserv/lib/python/lsst/qserv/wmgr/dbMgr.py", line 194, in createDb
>>>    dbConn = Config.instance().privDbEngine().connect()
>>>  File "/usr/local/home/becla/stack/repos/qserv/lib/python/lsst/qserv/wmgr/config.py", line 120, in privDbEngine
>>>    inst = engineFactory().getEngineFromArgs(**kwargs)
>>> NameError: global name 'engineFactory' is not defined
>>> 
>>> 
>>> See? That is so much better. I entered engineFactory instead of
>>> EngineFactory. There is no way I could have figured it out from the
>>> previous stack trace...
>>> 
>>> How can we improve that?
>>> 
>>> Jacek
>> 
> 

########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the QSERV-L list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=QSERV-L&A=1

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

March 2018
February 2018
January 2018
December 2017
August 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use